Reputation: 495
I'm a JSF beginner and I have an easy JSF question but I couldn't solve the logic here.
I open new mv.xhtml
page via commandbutton like this:
<p:commandButton value="#{grBean.protocolName(item)}"
onclick="window.open('/SearchMap/faces/mv.xhtml?url=#{item}')">
</p:commandButton>
And I have mvBean
which is a session scope. I get the url parameter with a function which is called in postconstructed init method. The method is like:
Map <String, String>tempMap= FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
if(tempMap.get("url") !=null)
url=tempMap.get("url");
The problem is here, as mvBean
is session scoped, the init method is called only once so I can't get a new url parameter naturally.
I want to use mvBean
as a sessionScoped coz I want to keep all the passing urls in an ArrayList.
So, how can I get the url parameter when I use session bean? Or do you have any suggestion or solution?
Thanks for help.
Upvotes: 1
Views: 1431
Reputation: 24403
You don't have to do it in init()
, here is a quick solution. Put this on your mv.xtml
page, somewhere inside <h:form>
<p:remoteCommand name="onload" action="#{mvBean.checkUrl()}" autoRun="true" />
and move your logic from init()
to public void checkUrl()
.
Upvotes: 1