If you are stuck without more elegant solutions, I would try something like
this:
...
function showErrorMessage(errorItem)
{
errorMessage = errorItem.alt;
...
...
...
<logic:messagesPresent property="time">
<html:messages id="errorText" property="time"/>
<jsp:useBean id="errorText" type="java.lang.String"/>
<html:text property="time"
onmouseover="javascript:showErrorMessage(this)"
onmouseout="javascript:resetErrorMessage();" styleClass="XXX"
alt="<%=errorText%>"/>
</logic:messagesPresent>
<logic:messagesNotPresent property="time">
<html:text property="time" styleClass="YYY" />
</logic:messagesNotPresent>Cheers,
Brief explanation:
The (nop) loop thru the html:messages just populates a pagecontext
bean with the (last) error message. The usebean makes it available as a
scripting variable. The "ALT" field is used to store the error message for
the field.
HTH,
Krishna
> -----Original Message-----
> From: Duan Qiang [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 11, 2003 12:44 PM
> To: Struts Users Mailing List
> Subject: how to get the error message in java code
>
>
> Hi,
>
> How can I get the error message for a certain field so that I
> can customize
> the field contents (styleClass)?
>
> What I need is to change the style class of a certain field
> if there is
> error message, and show the error message on the specified layer <div>
>
> For example,
>
> <html:text property="abc"
> onmouseover="javascript:showErrorMessage("<%=
> errorText %>")" onmouseout="javascript:resetErrorMessage();"
> styleClass="XXX" />
>
> The function showErrorMessage shows the error text for this
> field and the
> other resetErrorMessage cleares the error message. It seems
> that I need to
> get the errorText for this property but I do not know how.
>
> Thx for your help.
>
> Regards,
>
> Dq
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]