开发者

Dynamic Binding in jsf

开发者 https://www.devze.com 2023-02-14 22:02 出处:网络
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

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

精彩评论

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