3 Replies Latest reply: Mar 28, 2013 3:23 PM by Timo Hahn RSS

    Access page template attribute from non page template page programatically

    Michael Shapira
      Hi. I have page template where I defined an attribute "UserName" and it is bound to outputText on the page template header.
      Now in my non page template page I have a button.
      When I click the button I want to populate the attribute .
      I do the following on button click:

      FacesContext fctx = FacesContext.getCurrentInstance();
      ELContext elctx = fctx.getELContext();
      ExpressionFactory exprFactory = fctx.getApplication().getExpressionFactory();
      ValueExpression ve = exprFactory.createValueExpression( elctx, "#{attrs.UserName}",
      Object.class);
      //Object valueObject = ve.getValue(elctx);
      ve.setValue(elctx, "Test");

      but get this error:


      javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'attrs' resolved to null

      Please advice