The question was asked about using the beanclass attribute instead of
the action attribute. Here's the problem:
The beanclass attribute would bind to the action bean's URL binding
which is going to produce an "action" of:
*/share/0/_/add*
And that is fine in English but for Spanish the URL needs to be the
following so I am forced to specify my own URL in the action obtained
from the ActionBean:
*/compartir/0/_/anadir*
At which point Stripes throws up with the Error message when it
processes the form tag:
... Could not locate an ActionBean that was bound to the URL
[/compartir/0/_] ...
In the end... there are 2 issues with what Stripes is doing:
1) It is NOT conducive to externalized / pre-processed URI localization
with the "action" attribute. Yes its being smart... but too smart in
this case.
2) The error is not dramatic enough to be noticed but the form breaks in
a VERY spectacular way i.e. I spent 2 days trying to figure out why the
localization of my forms was not working in Spanish but was working in
English... I kept massaging resource bundles in vain... Stripes already
produces a message that it is unbound from a URL so I didn't readily
notice the error message... had Stripes thrown an Exception with a stack
trace then it would have been quite obvious what was going on.
So at the very least Stripes needs to throw an exception in this case
*AND* at the very least Stripes should allow a developer to work around
enforcing this verification especially if I end up supplying my own URL
in the action... OR... at least offer a switch like...
verifyUrlBinding="false" ... in the form tag that defaults to true.
Surely I am not the 1st to build a fully localized app with Stripes???
Thoughts anyone???
--Nikolaos
Nikolaos Giannopoulos wrote:
Actually the form tag fails even more spectacularly than I
suspected... as things like <s:label tags nested in the form are not
even localized.
Looks like Stripes wants to be smart and ensure that URLs map directly
to ActionBean's but that would make sense if Stripes offered full
fledged Localization support on UrlBindings (sure one could make shell
nested subclasses but that is ugly as it hard codes localization vs.
having it in re-loadable property files).
Perhaps what we need is an option on the form tag that signals to
Stripes to ignore the fact that there is no match to an ActionBean and
don't worry about it b/c the developer knows what they are doing.
Because although the default error behaviour is nice it doesn't make
sense with URI localization... .
In any event, would be interested in other people's thoughts /
solutions... .
--Nikolaos
Nikolaos Giannopoulos wrote:
Hi,
*/_Setup:_/
*
- ShareActionBean with
@UrlBinding("*/share/*{uuidRadix}/{titleUrlified}/{$event}")
- UrlRewriteFilter that pre-processes requests and maps say the
Spanish URL:
*/compartir/0/_/anadir* ==> */share/0/_/add*
/_*Flow:*_/
- User request: */compartir/0/_/anadir*
- UrlRewriteFilter forwards to: */share/0/_/add*
- ShareActionBean event handler simply does:
return (new*
ForwardResolution*("/WEB-INF/jsp/content/*share_form.jsp*"));
- *share_form.jsp* relevant snippet contains:
*<s:form* *action="${actionBean.formUrlBinding}"* method="POST">
<s:text name="share.title" />
<s:hidden name="*tokenKeyTx*" />
<s:submit name="yes" /><s:submit name="no" />
* </s:form>*
- *${actionBean.formUrlBinding}* resolves to */compartir/0/_ *so
the form tag ends up looking like:
<form action=" */compartir/0/_*" method="POST">
<input type="text" name="share.title" value="" />
<input type="hidden" name="*tokenKeyTx*" value="" />
<input type="submit" name="yes" value="yes" /><input
type="submit" name="no" value="no" />
* </form>
*- Now, what happens next was somewhat unexpected... as soon as the
form tag is processed the following error comes up:
ERROR net.sourceforge.stripes.tag.FormTag.error - Could not locate
an ActionBean that was bound to the URL [/compartir/0/_]. Without an
ActionBean class Stripes cannot determine whether the ActionBean is a
wizard or not. As a result wizard behaviour will be disabled.
- While I understand that Stripes is trying to make a 1-to-1
association between the form action and an existing URL binding the
problem is that the error appears to affect the binding of the
"tokenKeyTx" hidden field in the form in that it ends up with a value
of "" instead of its true value "83e32-32435254-sjfi-asbsdrwq".
I could probably live with an error being logged but why does Stripes
make this such a serious offence AND in light of localization isn't
this a problem???
I see 2 immediate workarounds to this problem though both aren't great:
1) Use non-localized action URL in the form but then I would need to
override Source page resolution b/c if there is an error in say user
input the user must be redirected to the localized version of the URL
and not the non-localized version. As well in order to maintain the
localized URL which could contain an id for example (say doing edit)
we would need to add a hidden form field for the localized URI...
this smells in that the URL in the action is non-localized and
although not directly visible to the user still appears silly to be
part of a fully localized web app and then we pack a hidden localized
URI. Uuuggghhh...
2) Add URL bindings for localized versions. This is not viable as we
are using UrlRewriteFilter to abstract localization from our
components and have invested heavily to abstract as much of that away
from Stripes as possible.
Thoughts? Other Solutions? Is this a flaw? Bug (in light of
localization)?
Thanks,
--Nikolaos
--
Nikolaos Giannopoulos
Director of Information Technology
BrightMinds Software Inc.
e. nikol...@brightminds.org
w. www.brightminds.org
t. 1.613.822.1700
c. 1.613.797.0036
f. 1.613.822.1915
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users