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

If in JSF - Conditionaly displaying content  RSS feed

 
Haris Karameh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have request bean on the page having property of char type.
I want to display different parts of the page depending in the char value, but I can not find the right synthax for it . Can somebody help me
The bean name is HBDRETURN and poperty is "type". When entering if my tool (Rational) generates following fragment:
<c:if test="${pc_test.HBDRETURN.type}"></c:if>
I want to test for two values and tried:
<c:if test="${pc_test.HBDRETURN.type}=='S'">Success</c:if>
<c:if test="${pc_test.HBDRETURN.type}=='F'">Failure</c:if>
and
<c:if test="#{pc_test.HBDRETURN.type}=='S'">Success</c:if>
<c:if test="#{pc_test.HBDRETURN.type}=='F'">Failure</c:if>

Rendered output is nothing.
If I try:
<h utputText id="text1" value="#{pc_test.HBDRETURN.type"></h utputText>
and result is 'S'
What am I doing wrong?
This is just simplified presentation of what am I trying to achieve. Conditionaly displayed content contains different tables and structures.
TIA Haris
 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mixing JSF and JSTL is a bit tricky, but I got it to work in several of my applications by doing the following:
 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, this form does not accept the TAB key...

You need to :
1) Ensure that the bean is in the SESSION scope
2) fully-qulify bean within your JSTL as ${sessionscope.BeanName.method}

Hope this works out for you!

Josh
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF doesn't need to work with JSTL. What you want can be achieved by using the rendered attribuate of components or a container component (panelGrid) and set the value to true or false depending on what needs to be shown. These boolean values are set in the backing bean when the request comes in. All logic should be done there. And it makes your JSP's a lot cleaner.

FYI - I like JSTL. Just not with JSF.
 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg is correct...that would be the preferred method. I have used that technique for "rendering"/"not rendering" components as needed.

Josh
 
Haris Karameh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using "rendered" attribute for textBoxes but it looks like the component does not pay attention to it.
I tried to bind the property to bean property where output is boolean, and
other one type of String returning "true" o "false" but the box is always rendered regarding of the value.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show some code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!