Search code examples
javajsficefaces

Passing values with ui:param and access them in Backing bean


-xhtml File

I cannot accsses the passed Parameter

<ui:insert>
        <ui:include src="#{PopUpBean.includeUrl}">
           <ui:param name="includeParam" id="includeParam" value="HalloWert!"  />                                  
        </ui:include>
</ui:insert>

Thats the way i tried to accses the parameters, i have lookedup every variable with help of the debugger, but it seems as if the ui:param value isn't passed:

    private void init () {
   FacesContext ctx =  FacesContext.getCurrentInstance();
   ExternalContext ectx = ctx.getExternalContext();
   Object o = ectx.getRequestParameterMap().get("includeParam");
   Object request =  ectx.getRequest();
}

@PostConstruct
public void postContruction () {
    this.init();
}

Thank you for help!


Solution

  • Found a Solution;

      HtmlOutputLabel ob = (HtmlOutputLabel) UiTreeWalker.findComponent(FacesContext.getCurrentInstance().getViewRoot(), "hiddenValue");
           ValueExpression vb = ob.getValueExpression("value");
          Object value =  vb.getValue(FacesContext.getCurrentInstance().getELContext());
    

    Hidden Value is a outputLabel with rendered = false

    The idea behind this is that you can put the parameter in a hidden value on your JSF page, and then you can access that parameter from this java snippet.