[ http://issues.apache.org/jira/browse/BEEHIVE-295?page=history ]

Jeremiah Johnson updated BEEHIVE-295:
-------------------------------------

    Attachment: newWebAppAndLogs.tar

I attached newWebAppAndLogs.tar to demonstrate some things that I learned from 
Eddie about the form beans.  That tarball contains four files: a new 
BEEHIVE-295.tar, cat.out.cancel, cat.out.nofax, and cat.out.withfax.  It seems 
that my enhancement request may be getting into an area that can't be 'fixed'.  
The difference between cat.out.nofax and cat.out.withfax is most informational 
about this.  Eddie can explain it better (and that information should get into 
some documentation), but the short answer is that all fields go to the 
expression evaluator for processing but the evaluator doesn't find a field 
matching something like {actionForm.fax} so it logs an ERROR and stack trace; 
however, the processing of the post isn't really broken because only fields in 
the form bean in use are required.

In the demo application, I have two actions and each take a different form 
bean.  Here are the form beans:
   public static class ContactForm extends FormData {
      private String name;
      private String phone;

   public static class LongerContactForm extends ContactForm {
      private String fax;

Notice that the longer contact form just adds a new field to the existing 
contact form.  Then, I have a form that is the union of all fields that I am 
interested in:
      <p><netui:form action="submitWithFax">
         Name: <netui:textBox dataSource="actionForm.name"/><br />
         Phone: <netui:textBox dataSource="actionForm.phone"/><br />
         Fax: <netui:textBox dataSource="actionForm.fax"/><br />
         <netui:button action="submitNoFax" type="submit" value="submit no 
fax"/>
         <netui:button type="submit" value="submit with fax"/>
         <netui:button action="cancel" type="submit" value="cancel"/>
      </netui:form></p>

What I am doing is legal, but you can see errors logged.  In fact, if I use the 
button marked 'submit no fax', then I get about 250 lines worth of ERROR logs 
even though the correct form bean is bound.  The errors generated are simply 
the expression evaluator saying the it has some expression that it can't handle.

I can understand the need for the log detail from the expression evaluator, but 
I think that error logs are too harsh.  Perhaps an info message saying 
'expression found "{actionForm.fax}" that doesn't map to any fields in the 
current form bean'?

- jeremiah


> change button tag to prevent RuntimeException
> ---------------------------------------------
>
>          Key: BEEHIVE-295
>          URL: http://issues.apache.org/jira/browse/BEEHIVE-295
>      Project: Beehive
>         Type: Wish
>   Components: NetUI
>  Environment: Beehive SVN / Tomcat 5.0.25
>     Reporter: Jeremiah Johnson
>     Assignee: Eddie O'Neil
>     Priority: Minor
>  Attachments: BEEHIVE-295.tar, catalina.out, log4j.xml, newWebAppAndLogs.tar
>
> If I use a button tag in a form to cancel and the action of that button 
> points to an action that doesn't declare a form bean, I get a 
> RuntimeException for every field in the form.  The exceptions seem harmless, 
> but I would rather not have the exception or have a single, specific 
> exception.
> I will attach the stack trace that I got using the following code:
> --- in the JSP
>          <netui:button type="submit" value="submit"/>
>          <netui:button action="cancel" type="submit" value="cancel"/>
>       </netui:form></p>
> ---
> --- in the controller
>       @Jpf.SimpleAction( name="cancel", returnAction="newProductCancel" )
>    }
> ---
> The obvious work-around (and probably correct use of the cancel action in 
> this case) work fine, so this isn't recorded as a bug against Beehive.
> --- the 'correct' controller code
> @Jpf.Action(
>    forwards={
>       @Jpf.Forward(name="success", returnAction="newProductCancel")
>    },
>    useFormBean="newProductForm"
> )
> protected Forward cancel( NewProductForm newProductForm ) {
>    return new Forward( "success" );
> }
> ---
> - jeremiah

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira

Reply via email to