You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by wolfgang <wo...@ybb.ne.jp> on 2002/11/12 16:33:00 UTC

about html:error ( error handling )

Hi there,

I'm trying to make an error handling in my web application with 
<logic:present> and <html:errors>.
but I'm stuck.

what I wanna do is that 
when struts catch the error (user didn't fill in the required textarea) ,
struts say there's an error.
And
even though there were no errors, strust says there was No error.

now I can do only former one with the code below...

In ApplicationResource.properties file ------
username.required=FF0000   (<-- red color in html)
---------------------------------------------

In ActionForm bean --------------------------
ActionErrors errors = new ActionErrors();
if(.....){
   errors.add("username", new ActionError("username.required"));
}
....
---------------------------------------------

In jsp --------------------------------------
<logic:present name="<%=Action.ERROR_KEY%>">
   <html:errors property="username">
</logic:present>
---------------------------------------------

when struts catches the error, the HTML( transformed from jsp ) write
out FF0000.

I want struts write a word I specified even though There's NO error.
Is it impossible ???

why I wanna do this is that I wanna change the font's color depending on
either error or not.

If there's error <font color="ff0000">foobar</font>
If there's NO error <font color="ffffff">foobar</font>

I tried coding in jsp.

<font color="
<logic:present name="<%=Action.ERROR_KEY%>">
   <html:errors property="username">
</logic:present>
<logic:notPresent name="<%=Action.ERROR_KEY%>">
   FFFFF
</logic:notPresent>
">foobar</font>

This does NOT work because if username property is okay , but other
properties got errors, <html:errors property="username"> will be
processed...

so I gotta do like below...(since I don't know how to code, I just write
words)

<font color="
<logic:present name="<%=Action.ERROR_KEY%>">
   if(this error is username property's one){
      <html:errors property="username">
   }else{
      write FFFFF
   }
</logic:present>
<logic:notPresent name="<%=Action.ERROR_KEY%>">
   FFFFF
</logic:notPresent>
">foobar</font>


I don't know how to code....

Please Please anyone helps me out...

Thanks in advance.
wolfgang



-- 
wolfgang <wo...@ybb.ne.jp>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>