• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

logic i JSF

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any functionality in JSF as the Struts logic tags?
I'm thinking of logic:equal etc.
What i try to do, is to open a JSF page in either 'edit' or 'create new' mode. When the id of the backing bean is set, i would like put 'Edit this object' in the title of page,when it's empty 'Create new object'.
Are there other ways to do this?
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Placing logic on your view is considered a Bad Thing, despite what Struts and JSTL permit - it violates the Sepation of Concerns Philosophy makes a mockery of the Model/View/Controller paradigm, since you are in effect, embedding part of the controller in the View.

The closest JSF wants to get to it is conditional tag rendering.

I've done what you're asking about in 2 ways. One was to have 2 buttons and render only the applicable one. More recently I've preferred one button and a getter on the backing bean that returns the (possibly internationalized) word "Create" or "Update". I also normally include 2 other getters, one for "isCreateMode" and one to return the caption string for the page appropriate for the context.

I tried reducing the number of getters by doing EL expressions on the view, but the results were both ugly and frustrating.
 
reply
    Bookmark Topic Watch Topic
  • New Topic