• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to eliminate code repeating in jsf page?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Josh,

I have another solution



 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice one...that will definitely do the trick!
 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic