Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Commandlink or OutputText ?

 
Francisco Llaryora
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , to all.

I dont know what is the component that put Commandlink or OutputText (for example ) if a integer property is 1 or 2 (true or false).

<componentUnknow value="#{bean.conditional}">
</h:Commandlink value="Is open!" action="go to the next page">
<h:OutputText >sorry...Is close</h:OutputText >
</componentUnknow>

thanks for readme.!
 
Francisco Llaryora
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/213739/JSF/java/JSTL-if-tag-not-working

OK, thanks Ketan Jambhekar !
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18002
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This assumes that you have a boolean property named "closed" on "bean". An actual 1 or 2 isn't a good set of values to use for binary values. And, while in a lot of languages, it's common to use 0 or 1, that doesn't work in Java, which doesn't treat booleans like they are numbers.

If an internal 1-or-2 value is required, define the following method:


I do not recommend simply using EL to test the numeric value directly.
 
Francisco Llaryora
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim Holloway, thanks for reply!

I'm newbie in JSF programming but old Java programmer.

Thanks for the example.
Ok : it is a sin if i put logic in JSF instead of the business layer.

i will write again if i have a new doubt .
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18002
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's not a "sin". That implies the sort of pompous dogma that form the edicts of mediocre managers. In this particular case, I'm putting aside my innate pompousness in favour of being devious and evil. For you see, there's a method to this madness:

1. Debugging Java code is easy. Debugging EL is . Hence, my admonition to avoid complex EL code.

2. If you keep the code in the Model and the display definition in the View then you always know which file to find something in without having to go on a "treasure hunt". And, even more importantly, you only have to look at one file listing when doing maintenance instead of bouncing back and forth between 2 of them (the Model and the View). In JSF you don't write much (if any) Controller code, although of course, when you do, it should be placed in the "Controller" place.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic