I like to follow-up on Nikolaos remarks about clean URLS and forms not
working as expected.

When using the <stripes:form> tag for action beans that have an @URLBinding
annotation with parameters, the <stripes:form> tag ignores those parameters
and thus generates an unexpected and incorrect form action URL.

I'm under the impression that this could be fixed by altering the
'setBeanclass' and 'doStartTag' method on the
net.sourceforge.stripes.tag.FormTag class. If these methods became aware of
the parameter defined in the @URLBinding of the ActionBean it would be
possible to generate a complete URL. The parameter values themselves could
be 'get' from the current action bean by using the Java reflection API.

This would of course only work when the action bean handling the form
forwards to the JSP with the form (MVC pattern). So we might want to make
this behavior optional.

Would this be a good solution to this problem? 


-----Original Message-----
From: Nikolaos Giannopoulos [mailto:nikol...@brightminds.org] 
Sent: Saturday, 20 November, 2010 23:37
To: Stripes Users List
Subject: Re: [Stripes-users] Stripes forms and Clean Url binding?

Oops... was playing around with a number of solutions. This one won't work
because it didn't solve the fact that form action="/article" is unable to
hit the @UrlBinding for the ArticleActionBean.

So far what appears to work is doing the following:
<s:form action="${actionBean.formUrlBinding}" method="POST">

And then having on the action bean:

public String getFormUrlBinding() {
StringBuilder sb = new StringBuilder();
sb.append("/article/").append(this.authorId).append('/').append(this.id).app
end('/').append(this.titleUrlified);
return (sb.toString());
}

Still appears to be a hack as I am duplicating the @UrlBinding but at least
its encapsulated in the ActionBean... if that is any solace ;-)

Cheers,

--Nikolaos



Nikolaos Giannopoulos wrote:
> Hi,
>
> So I figured out a solution to the problem:
>
> <s:hidden name="authorId"></s:hidden>
> <s:hidden name="id"></s:hidden>
> <s:hidden name="titleUrlified"></s:hidden>
>
> At first I thought it would be nice to force Stripes to build the 
> complete @UrlBinding i.e. it is already obviously consulting the 
> @UrlBinding to produce "/article" but understand why it isn't so. Even 
> in my case above I didn't want "event" to be the same so I guess this 
> offers the most flexibility... because how far do you go in binding 
> parameters is not black & white.
>
> Cheers,
>
> --Nikolaos
>
>
>
> Nikolaos Giannopoulos wrote:
>   
>> Hi,
>>
>> We have the following Url binding:
>> @UrlBinding("/article/{authorId}/{id}/{titleUrlified}/{$event}")
>>
>> And when we direct to the following url:
>> /web/article////add
>>
>> It does a ForwardResolution to a form which contains:
>>             <s:form
>> beanclass="org.test.ui.web.action.content.ArticleActionBean"
method="POST">
>>                 ...
>>                 <s:submit name="save" />
>>                 <s:submit name="cancel" />
>>             </s:form>
>>
>> However the HTML output is as follows:
>>             <form action="/web/article" method="POST">
>>                 ...
>>                 <input name="save" value="Save" type="submit" />
>>                 <input name="cancel" value="Cancel" type="submit" />
>>             </form>
>>
>> But the action ="/web/article" isn't sufficient to hit our Url 
>> binding... when we click on the "save" or "cancel" buttons???
>>
>> Am I missing something obvious like in the case of addParameter on 
>> RedirectResolution?
>>
>> Anyone?
>>
>> --Nikolaos
>>
>>     


----------------------------------------------------------------------------
--
Beautiful is writing same markup. Internet Explorer 9 supports standards for
HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to