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

How can I optimize this for JSF?  RSS feed

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to move my stuff into JSF. Being new, I figure there are a couple of optimizations I can make. How would I convert the below to JSF tags?

<% if (request.getAttribute("loginError") != null){%>
<span style="color:#FF0000">
<%= request.getAttribute("error") %>
</span>
<%}%>

Thanks, - Dave
 
Andres Quinones
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<h:panelGroup rendered="#{requestScope.loginError != null}">
<hutputText value="#{requestScope.error}" style="color:#FF0000;"/>
</h:panelGroup>

I think this could work for you.


Originally posted by Dave Alvarado:
Hi,

I'm trying to move my stuff into JSF. Being new, I figure there are a couple of optimizations I can make. How would I convert the below to JSF tags?

<% if (request.getAttribute("loginError") != null){%>
<span style="color:#FF0000">
<%= request.getAttribute("error") %>
</span>
<%}%>

Thanks, - Dave
 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or a more JSF-like way to do it would be to bind your loginError and error values into a backing bean in the faces-config and then use <h:messages /> and generate a message depending on whether or not loginError is null:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!