Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Evaluate Value from EL-String  RSS feed

 
Mario Luef
Greenhorn
Posts: 6
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guyz,

i want to evaluate a String which is a EL-Path in a property. Here is my Code:



So i have a list of Components which have to be rendered - this componentdefinition also contains the targetProperty from the Object which has to be edited.
In my param 'val' i have the way to the targetproperty as example 'contentBean.toEdit.description'
BUT my text entry only writes 'contentBean.toEdit.description' so it doesn't get resolved. Is there a solution?

Thanks in advance

EDIT:
Sorry Guyz found it :
<ace:textEntry value="#{contentBean.toEdit[rComp.targetProperty]}"></ace:textEntry>
now it gets evaluated at request time :)
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to see you fixed it, but mixing JSF and JSTL is a good way to get in trouble.

I realize that Oracle has been posting some JSF docs with JSTL in them, but JSTL and JSF originally didn't get along very well at all, and even now people frequently run into problems.

One reason for that is because JSTL is basically a "programming language" and JSF is a Model/View/Controller implementation where the View is supposed to be a template, not a container for logic.

JSTL was designed for traditional JSPs, which compiled into java servlet code, so adding code to code was OK. JSF View Templates (xhtml) are not compiled into code, they're compiled into a Component Tree data structure, so a "code" approach doesn't work as well.

Beyond that, when you have code on both Model and View, it becomes a "treasure hunt" to find out which side of the equation a given function is on. Or worse, yet, if it's on both. That's an expensive way to design things.
 
Mario Luef
Greenhorn
Posts: 6
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Glad to see you fixed it, but mixing JSF and JSTL is a good way to get in trouble.

I realize that Oracle has been posting some JSF docs with JSTL in them, but JSTL and JSF originally didn't get along very well at all, and even now people frequently run into problems.

One reason for that is because JSTL is basically a "programming language" and JSF is a Model/View/Controller implementation where the View is supposed to be a template, not a container for logic.

JSTL was designed for traditional JSPs, which compiled into java servlet code, so adding code to code was OK. JSF View Templates (xhtml) are not compiled into code, they're compiled into a Component Tree data structure, so a "code" approach doesn't work as well.

Beyond that, when you have code on both Model and View, it becomes a "treasure hunt" to find out which side of the equation a given function is on. Or worse, yet, if it's on both. That's an expensive way to design things.


Hi Tim,

thanks for the response, but in this case I wouldn't say that there is that much logic inside - i just use the JSTL for building up the right component tree.
the <c:foreach> can be replaced by <ui:repeat> and
the <c:if> can be replaced by a <ui:fragment rendered=....> and all the JSTL is gone.

A good explanation of the difference between JSTL and JSF is on this page:
JSF vs JSTL

br
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!