myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joost Schouten" <jo...@jsportal.com>
Subject RE: JSTL and JSF
Date Wed, 17 Jan 2007 07:15:29 GMT
Thanks Simon!

That did the trick. And no more <c:xxx/> tags for me ;-)

Cheers,
Joost
-----Original Message-----
From: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
Sent: Wednesday, January 17, 2007 4:14 PM
To: MyFaces Discussion
Subject: Re: JSTL and JSF

Joost Schouten wrote:
> Hi,
> 
> I have the below code trying to print a dataTable when the backing bean
> found entries, or "no results" when none are found. But my JSTL tags don't
> seem to have access to my JSF backing beans. What is the best way to
combine
> JSTL and JSF, or are the other JSF tags/attributes I should use for this
> purpose?
> 
> My table gets printed nicely without the JSTL c:if and c:choose tags
> 
> Thank you,
> joost
> 
> <h:form id="searchResults" onsubmit="return validateForm(this);">
> <c:if test="#{jsp$searchResults.query!=null">
> 	<c:choose> 
> 	  <c:when test="${jsp$searchResults.hits > 0" > 
> 	<!-- only show the dataTable if there is a query -->	
> 		<t:dataTable 


Combining JSTL conditional tags (or loops) with JSF+JSP1.1 is a very bad 
idea; it can result in very weird behaviour.


Instead, do:
   <t:dataTable rendered="#{searchResults.hits > 0}" ....>
   </t:dataTable>

   <t:outputText rendered="#{searchResults.hits == 0}"
      value="No results"/>

Regards,

Simon



Mime
View raw message