After clicking on an image, the user is redirected to a new page like:
/viewPalermoUser.seam?accountId=100245
with the code:
<s:link title="#{messages['palermo.userlist.view']}" view="/portal/custom/palermo/administration/viewPalermoUser.xhtml"
propagation="none">
<f:param name="accountId" value="#{account.id}"/>
<img src="/static/portal/customer/palermo/find.png" style="border:none"/>
</s:link>
There is a backing bean where i take the account id and print the account information for that user (when the page is first rendered all it's ok).
BUT have a rich tab panel and a search button. Whenever i press one of this, the accountId value is NULL, although in the url it is the OK, so it has a real value.
I do not understand why the accountId's v开发者_如何学JAVAalue is lost if a postback occurs?
I take the accountId like:
@RequestParameter
private Long accountId;
Can anyone give me a clue?
UPDATE: Finally it works. Use page param like Petar suggested. Had problems until i realized that:
A seam page param is not available in @Create method of the backing bean. Workaround: create a page action to use this param. (must be usefull for others)
Thanks.
As far as I know, @RequestParameter works only on an initial request. To solve the problem, you can use a Seam page parameter. Put in your page.xml descriptor the following tag:
<param name="accountId" value="#{backingBean.accountId}"/>
You don't need the @RequestParameter annotation.
After clicking on an image, the user is redirected to a new page - I suppose it is called /viewPalermoUser.xhtml
First of all, a simple request parameter does not survive a postback.
To solve your problem, you can create a page parameter
<page view-id="/viewPalermoUser.xhtml">
<param name="courseId" value="#{courseHome.courseId}"/>
</page>
So when Seam notices
<param name="courseId" value="#{courseHome.courseId}"/>
It creates a page parameter and because of value attribute (not required), it is assigned to courseHome.courseId property. Page parameter survives JSF postback.
If you want accountId survive a postback in s:link (or s:button), you have to create a page parameter in the view-id that matchs s:link view="/portal/custom/palermo/administration/viewPalermoUser.xhtml" attribute
So we need
<page view-id="/portal/custom/palermo/administration/viewPalermoUser.xhtml">
<param name="courseId"/>
</page>
When using page parameter, you do not have to worry about f:param. s:link takes care of it. So your accoutId page parameter is automatically appended to the link.
<s:link title="#{messages['palermo.userlist.view']}" view="/portal/custom/palermo/administration/viewPalermoUser.xhtml"/>
regards,
精彩评论