Raspoutine
Raspoutine

Reputation: 82

Passing parameter between two pages without using the url in JSF and session's variable

I have a page object.xhtml which display the list of objects. I want to click on one object and show its details on another page. I don't want to pass parameter via the url or using session's variable.

Upvotes: 2

Views: 9312

Answers (1)

Jorge Iten Jr
Jorge Iten Jr

Reputation: 362

Assuming you are using a p:datatable you can create a column to redirect to an edit page:

                <p:column headerText="Action">
                    <p:commandLink ajax="false" title="Edit" action="target.xhtml"
                        value="Edit">
                        <f:param name="objectId" value="#{object.id}" />                        
                    </p:commandLink>
                </p:column>

And in your backing bean you can use the parameter like this:

    FacesContext context = FacesContext.getCurrentInstance();
    String objectId = context.getExternalContext()
                .getRequestParameterMap().get("objectId");

Upvotes: 2

Related Questions