You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bj...@accenture.com on 2007/02/12 10:54:48 UTC

Equivalent logic:messagesPresent in JSTL

Is there an equivalent in JSTL for the logic :messagesPresent ?  I've looked on Google, but I can't find a decent example.  Someone suggested <c:if test="${! Empty requestScope['org.apache.struts.action.ERROR'}"> but that doesn't work.  I also need to test if a certain property is added, so I can put certain labels in red (read, add a css-class to a span if a specific property is added. E.g. <span<logic:messagesPresent property="txtUserName"> class="errorMsg"</logic:messagesPresent>>Username:</span>)

Tia

Bjorn 

 



This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

Re: Equivalent logic:messagesPresent in JSTL

Posted by Laurie Harper <la...@holoweb.net>.
bjorn.de.bakker@accenture.com wrote:
> Is there an equivalent in JSTL for the logic :messagesPresent ?  I've looked on Google, but I can't find a decent example.  Someone suggested <c:if test="${! Empty requestScope['org.apache.struts.action.ERROR'}"> but that doesn't work.  

JSTL has no direct equivalent, since message management is a Struts 
feature, which JSTL knows nothing about. The snippet you posted should 
be roughly right. It should be '! empty' rather than '! Empty', the 
value may be in session rather than request scope, and if you're 
actually looking for messages rather than errors the name of the 
constant is different.

 > I also need to test if a certain property is added, so I can put 
certain labels in red (read, add a css-class to a span if a specific 
property is added. E.g. <span<logic:messagesPresent 
property="txtUserName"> 
class="errorMsg"</logic:messagesPresent>>Username:</span>)

Can you get the effect you want using the errorStyle / errorStyleClass / 
errorStyleId properties of the html:* input tags? If not, you may be out 
of luck since the ActionMessages/ActionErrors classes aren't Map-like :(

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org