Java Reference
In-Depth Information
Tim Says. . .
Don't Violate Conventions with @UrlBinding
By default, Stripes will create URLs for all action beans such that
they all follow a consistent convention. Freddy has shown you
how to modify that convention to suit your own needs and how
to use @UrlBinding to both implement clean URLs and override
conventions with specific URLs. In my opinion, even when using
@UrlBinding to implement clean URLs, you should try your hardest
to stick to your URL naming convention!
When developing, it's helpful to be able to see a class name
and immediately know what its URL will look like. For example,
you see a class called awesome.SuperDuperActionBean , and you
know it'll map to /awesome/super_duper , not to some other URL
like /worlds_best_bean . But this isn't such a big deal—if you know
the class name, you can always check the class to get its URL,
right?
The better reason is this: when testing your application and
something goes wrong, it's very handy to be able to look at
the URL and be able to guess the action bean that's being
called. In this case, if the URL doesn't follow your convention,
then you have to search your entire project to figure out which
action bean you want. Speaking from experience, this can be
time-consuming and frustrating!
This calls the view event handler. Do not include more than one
parameter that matches an event name; otherwise, Stripes will
complain!
Notice that the value of the parameter is ignored, so it can be
anything or nothing at all.
• Embed the event name in the URL by using {$event} in @UrlBinding ,
and construct the URL accordingly.
• Append a slash (/) and the event name after the part of the URL
that binds to the action bean. For example, if the action bean
is bound to /action/contact_list , /action/contact_list/view targets the
view event handler. This is equivalent to the following:
@UrlBinding("/action/contact_list/${event}")
except that we don't need to add the annotation.
 
 
Search WWH ::




Custom Search