• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to eliminate code repeating in jsf page?

 
Pavels Hlopoks
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have code



If and else part is little bit different, parameter SELECTED value is different.

how better to eliminate code repeating in jsf page in this situation?

Thanks!
 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure exactly what you are attempting to perform, but you should be able to tie the selected attribute to a backing bean value. In coding this way, your backing bean will determine if the value is true or false. You can get rid of the JSTL altogether and just do something like this:

<tr:commandNavigationItem immediate="true"
text="Contracts"
action="guide.page"
selected="#{bean.selectedValue}"/>

I do not use JSTL anywhere in JSF code at this time unless absolutely necessary. You should try to perform all comparisons and business logic within the backing beans if possible.

I hope this will work for your situation. Otherwise, your JSTL solution may be the best alternative.
 
Pavels Hlopoks
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Josh,

I have another solution



 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice one...that will definitely do the trick!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!