Java Reference
In-Depth Information
hello.jsp
${actionBean.date}
<s:link
beanclass="stripesbook.action.HelloActionBean"
event="randomDate">
stripesbook/action/HelloActionBean.java
public Date getDate()
public Resolution randomDate()
Figure 2.3:
Binding a JSP to an action bean
Event Handlers
The currentDate ( ) and randomDate ( ) methods in the action bean are
event handlers. But what makes Stripes recognize these methods? We
didn't declare them in a configuration file. The method names don't
have a special prefix or suffix. It's all in the method signature. An event
handler is a method that does the following:
• Is declared as public
• Returns a Resolution
• Takes no parameters
• Is defined in an action bean
We choose the name of the method, and that becomes the name of the
event handler. In HelloActionBean , the two event handlers are named
currentDate and randomDate .
When we start the application and the initial request is made to Hel-
loActionBean , how does Stripes know which event handler to execute?
Here's where the notion of a default event handler comes in. When no
event handler is specified (either because of a plain URL or with an
<s:link> tag with no event= attribute), the default event handler is trig-
gered. Stripes treats an event handler as the default when
• the event handler is annotated with @DefaultHandler , and
• the event handler is the only one defined in the action bean.
 
 
 
Search WWH ::




Custom Search