Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

logic i JSF  RSS feed

 
robert isidorson
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!