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

binding and el expression in datatable  RSS feed

 
sudharshan tettu
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
how can we pass an el expression to datatable in xhtml?

For example
<c:set var="tempparam" scope="request" value="#{backingbean.nameofbinding}" />
<h:datatable binding="#{tempparam}" ....></h:datatable>

i get that tempparam from some other request object.How can we set it as an el expression for binding instead of plain string.


Thanks
Sudharshan Tettu
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first off, get rid of the JSTL. JSTL and JSF don't go together well, and you don't need JSTL for JSF anyway. I also discourage using "binding" on controls unless you actually intend on dynamically rearranging the UI. Value binding is simpler, cleaner and doesn't require you to burden your backing bean with arcane JSF-specific code.

Secondly, there's absolutely no problem with using a symbolic value in EL expressions. I have lots of cases where I do a <ui:include> that passes the name of a component to the included xhtml to be dynamically substituted using the <ui:param> element. The only limitation is that while most JSF attributes may be EL expressions, some have to be fixed text, so it's always good to check the documentation on the tag in question. Things like value bindings, however, usually can be EL, so that's not much of a problem.
 
sudharshan tettu
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am not getting you could you please give me an example how can I dynamically substitute the value for binding at runtime using ui:param
Thanks
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Excerpt from included file listing.xhtml
">
 
sudharshan tettu
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim ,but my issue with binding for example we customized it like this
<ht:datatable binding="#{mytable}">
<h:column>
#{mutable.rowIndex}
</h:column>
</ht:datatable>


And in my datatable it's just an xhtm page where I would be invoking the jsf datatabl with some customization.
Like


<h:datatable binding="#{binding}">
<ui:insert/>
</h:datatable>

But my problem is the binding attr we used inside the column is not getting resolved when we pass it like that into the XHTML(the tag)


 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<ui:insert> is really not a good way of doing stuff like that. Use ui:insert for things like simple string values and use ui:include for more complex elements.
 
sudharshan tettu
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey tim I got it, let me try with ui:include and other workarounds
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!