开发者

Dynamic Binding in jsf

I am having an issue with Dynamic Binding in JSF page I am using JSF 1.1

All I want is manager to have the Manager Name Dynamic

<%String  manger="ManagerName";%>

The above code is just an Snippet it would come as a request parameter

code from the jsf file

<h:inputText id="street1" value="#{address.street1}"
binding = "#{<%=manager%>.billingStreet}" 
/>

This is the error which I am getting currenlty

enter code here

Caused by: org.apache.commons.el.parser.ParseException: Encountered "<" at line 1, column 3.
Was expecting one of:
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    "null" ...
    "(" ...
    "-" ...
    "not" ...
    "!" ...
    "empty" ...
    <IDENTIFIER> ...

    at org.apache.commons.el.parser.ELParser.generateParseException(ELParser.java:1895)
    at org.apache.commons.el.parser.ELParser.jj_consume_token(ELParser.java:1779)
    at开发者_Python百科 org.apache.commons.el.parser.ELParser.Expression(ELParser.java:124)
    at org.apache.commons.el.parser.ELParser.AttrValueExpression(ELParser.java:96)
    at org.apache.commons.el.parser.ELParser.ExpressionString(ELParser.java:43)
    at org.apache.myfaces.el.ELParserHelper.parseExpression(ELParserHelper.java:83)
    ... 49 more


You can't mix scriptlets <% %> and EL ${ }. Use the one or the other.

Since it comes from a request parameter, just access it as ${param.name} in EL. If the bean is in the request scope, then you can then access it by ${requestScope[param.name]}. So:

<h:inputText id="street1" value="#{address.street1}"
    binding = "#{requestScope[param.name].billingStreet}" 
/>

For a session scoped bean, use #{sessionScope} instead.


Unrelated to the problem/question, this design/approach smells.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜