target view's setter not called with f:param and f:viewParam
pmany posts regarding this topic, i think i have it right but my target
bean's setter is not being called. this is on jsf mojarra 2.1.25 with PF
3.5 on tomcat. /p ppage1.xhtml has/p precodelt;f:view
contentType=text/htmlgt; lt;h:bodygt; lt;h:link outcome=page2 value=goto
page2 via h:link passing familyId=50 with a f:param style=margin:0gt;
lt;f:param name=familyId value=50 /gt; lt;/h:linkgt; lt;/h:bodygt;
lt;/f:viewgt; /code/pre ppage2.xhtml supposed to receive that familyId
value via f:viewParam, but TestViewParam's setter for familyId is never
invoked. page2.xhtml is as follows./p precodelt;f:view
contentType=text/htmlgt; lt;f:metadatagt; lt;f:viewParam name=familyId
value={testViewParam.familyId} required=true /gt; lt;f:event
type=preRenderView listener=#{testViewParam.preRenderView} /gt;
lt;/f:metadatagt; lt;h:bodygt; ... /code/pre pand lastly,
TestViewParam.java/p precode@ManagedBean(name=testViewParam) @ViewScoped
public class TestViewParam implements Serializable { String familyId;
public void preRenderView(ComponentSystemEvent event) { if
(!FacesContext.getCurrentInstance().isPostback()) { // getting from req
param map works, // but setFamilyId(..) never called FacesContext ctx =
FacesContext.getCurrentInstance(); Maplt;String, Stringgt; parameters =
ctx.getExternalContext().getRequestParameterMap(); if
(parameters.containsKey(familyId)) { this.familyId =
parameters.get(familyId); } } } public String getFamilyId() {return
familyId;} public void setFamilyId(String familyId) {this.familyId =
familyId;} /code/pre
No comments:
Post a Comment