Hi
I want to pass the data from one JSF page to another without using query string.
Any idea how this can be done??

Recommended Answers

All 5 Replies

Session

I have tried all that..all resulting into null pointer exceptions, probably I have gone wrong somewhere. Please advise.

Well then post your session coding attempt and I'm sure someone will look at it. Without code we are just hypothetically talking about issue... not really productive

I have tried the following.
I managed to get the value from the parent window to the popup. But I am unable to fetch that value in processAction method of the FacesPortlet.
request.getAttribute("attributeName"); returns null.

public class ModelManagedBean {

	public static final String
		SHARED_STRING_KEY = “sharedStringKey”;

	public String getSharedString() {
		return PortletSessionUtil.getSharedSessionAttribute(
			SHARED_STRING_KEY);
	}

	public void setSharedString(String value) {
		PortletSessionUtil.setSharedSessionAttribute(
			SHARED_STRING_KEY, value);
	}
}

public class PortletSessionUtil {

	public static Object getSharedSessionAttribute(
		String key) {

		FacesContext facesContext =
			FacesContext.getCurrentInstance();

		ExternalContext externalContext =
			facesContext.getExternalContext();

		PortletSession portletSession =
			(PortletSession) externalContext().getSession(false);

		return portletSession.getAttribute(
			key, PortletSession.APPLICATION_SCOPE);
	}

	public static void setSharedSessionAttribute(
		String key, Object value) {

		FacesContext facesContext =
			FacesContext.getCurrentInstance();

		ExternalContext externalContext =
			facesContext.getExternalContext();

		PortletSession portletSession =
			(PortletSession)externalContext().getSession(false);

		portletSession.setAttribute(
			key, value, PortletSession.APPLICATION_SCOPE);
	}
}

getAttribute method here returns null as well

For anyone who might be interested. This is what I have done.
The second page is a popup so in page2 i use the following code.

window.opener.document.getelementbyID["element name"];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.