FIXED :) maybe a potential bug? (for my servlet container anyway)

PROBLEM:

Custom tag constructor only been called once by the servlet container
(Weblogic 8.16) in a jsp with multiple tag declaration of the same
type. As a result 'getAttributes().put("type", "the type here")' is
only been called for first tag declaration, all subsequent tags have
their 'type' missing from the attributes map.

SOLUTION

Added the type to attributes map within an initialise method as
opposed to constructor which gets called for every tag instance.
Here's a list of the tags I needed to amend, in each instance I
removed the (now) empty constructor and put
'getAttributes().put("type", "type here)' within an init method:

Tag                         Method moved to
========================
*InputCheckBoxTag : doInitBody()
*InputHiddenTag : doInitBody()
*InputTextTag :  doInitBody()
*InputButtonTag : doInitBody()
*InputFileTag : doStartInputTag()
*InputHiddenTag : doInitBody()
*InputImageTag : doStartInputTag()
*InputPasswordTag : doInitBody()
*InputRadioButtonTag : doInitBody()
*InputResetTag : doInitBody()
*InputSubmitTag : doInitBody()

Could this be a potential bug? Would it be better to move the code
here? I can only assume that my servlet container instantiates one
object per tag  and reuses that same instance to render any other tag
declaration of the same type.

Cheers,
Phil


On Wed, Jul 22, 2009 at 4:35 PM, phil
darley<[email protected]> wrote:
> Just to add more info, here's an example:
>
> jsp:
>
>  <stripes:form class="com.home.ui.action.services.ExampleActionBean"
> name="multipleElements" action="post">
>       <p>
>            name: <stripes:text name="name"/>
>       </p>
>       <p>
>           <stripes:submit name="hello" value="hello" class="btn"/>
>           <stripes:submit name="goodbye" value="goodbye" class="btn"/>
>       </p>
>   </stripes:form>
>
> html:
>
> <form action="post"
> class="com.home.ui.action.services.ExampleActionBean"
> name="multipleElements" method="post">
>       <p>
>            name: <input type="text" name="name" />
>       </p>
>       <p>
>
>           <input value="hello" type="submit" class="btn" name="hello" />
>           <input value="goodbye" class="btn" name="goodbye" />
>       </p>
>  <!--removed hidden soruce page element-->
> </form>
>
> action bean:
>
>  public String name;
>
>    public Resolution hello(){
>        getContext().getMessages().add(new SimpleMessage("hello " + name));
>
>        return new RedirectResolution(WelcomeActionBean.class,"view");
>    }
>    public Resolution goodbye(){
>        getContext().getMessages().add(new SimpleMessage("goodbye " +
> name));
>        return new RedirectResolution(WelcomeActionBean.class,"view");
>    }
>
> Results in:
>
> WARN  net.sourceforge.stripes.exception.DefaultExceptionHandler  -
> Unhandled exception caught by the Stripes default exception handler.
> net.sourceforge.stripes.exception.StripesRuntimeException: Multiple
> event parameters [hello, goodbye] are present in this request. Only
> one event parameter may be specified per request. Otherwise, Stripes
> would be unable to determine which event to execute.
>
> It was my understanding that multiple submit events could be rendered
> and only the submit 'clicked' would be past to the action bean.
>
> cheers,
> Phil
>
> On Wed, Jul 22, 2009 at 10:30 AM, phil
> darley<[email protected]> wrote:
>> Hi,
>>
>> If I try and add multiple submit buttons on one form only the first
>> submit is rendered correctly, the others have the
>> 'type="submit"attribute missing on the html element. Has anybody come
>> across this before?
>>
>> Cheers,
>> Phil
>>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to