You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by zuquirio <zu...@gmail.com> on 2008/01/07 15:11:20 UTC
Struts 2: Multiple methods in an action Class
Hi,
I've a strange bug. I create an action class with three methods: view(),
check(), do(). These three methods are in one class. In my
struts-config.xml, I have made the following entries:
<action name="letterRequestIndex" class="springLetterRequestIndex"
method="view">
<result
name="success">/WEB-INF/application/modules/letterrequest/index.jsp</result>
</action>
<action name="letterRequestCheck" class="springLetterRequestCheck"
method="check">
<result name="input"
type="redirectAction">letterRequestIndex</result>
<result
name="add">/WEB-INF/application/modules/letterrequest/addDetails.jsp</result>
<result name="success"
type="redirectAction">letterRequestDoRequest</result>
</action>
<action name="letterRequestDoRequest"
class="springLetterRequestDoRequest" method="do">
<result
name="success">/WEB-INF/application/modules/letterrequest/viewStatus.jsp</result>
<result
name="add">/WEB-INF/application/modules/letterrequest/index.jsp</result>
</action>
When I call an action, i.e.: letterRequestDoRequest, this method is repeated
3 to 5 times. My question is: Why this action is repeated 3 to 5 times? Can
you help me?
The method called within the letterRequestDoRequest action is:
public String do() throws PortletException{
this.session =
PortletActionContext.getRequest().getPortletSession();
LetterInfo letterInfo = new LetterInfo();
letterInfo.setTypeOfLetter((TypeOfLetter)this.session.getAttribute(TYPE_OF_LETTER));
if
(letterInfo.getTypeOfLetter().getCode().equals(
TypeOfLetter.CONSULAR.getCode())){
if
(this.getLetterInfo().getRecipient().trim().length() == 0){
setLetterInfo(letterInfo);
return ADD;
} else {
letterInfo.setRecipient(getLetterInfo().getRecipient());
}
} else {
letterInfo.setRecipient("");
}
letterInfo.setDateOfRequest(new Date());
letterInfo.setStatus(TypeOfStatus.UNPROCESSED);
if
(BasicUtils.isFromThursdayToFriday(letterInfo.getDateOfRequest())) {
setStatusMessage(getText("label.afterNextFriday"));
letterInfo.setDateOfDelivery(
BasicUtils.getNextDay(
letterInfo.getDateOfRequest(), Calendar.FRIDAY, 1));
} else {
setStatusMessage(getText("label.nextFriday"));
letterInfo.setDateOfDelivery(
BasicUtils.getNextDay(
letterInfo.getDateOfRequest(), Calendar.FRIDAY, 0));
}
setLetterInfo(letterInfo);
this.letterRequestService.create(letterInfo);
this.session.removeAttribute(TYPE_OF_LETTER);
return SUCCESS;
}
Thanks in advance!!
--
View this message in context: http://www.nabble.com/Struts-2%3A-Multiple-methods-in-an-action-Class-tp14666539p14666539.html
Sent from the Struts - User mailing list archive at Nabble.com.
Re: Struts 2: Multiple methods in an action Class
Posted by zuquirio <zu...@gmail.com>.
Thanks a lot! I will give it a try. Actually the real method's name is:
doRequest, I will try to put a different name. Thanks.
Ted Husted wrote:
>
> What happens if you use a method name other than "do".
>
> There's actually a feature in Struts 2 where we can name a method
> "doDefault" and then refer to it as "default" elsewhere. Naming a
> method "do" might be confusing.
>
> HTH, Ted
> * <http://www.StrutsMentor.com/>
>
> On Jan 7, 2008 9:11 AM, zuquirio <zu...@gmail.com> wrote:
>>
>> Hi,
>> I've a strange bug. I create an action class with three methods: view(),
>> check(), do(). These three methods are in one class. In my
>> struts-config.xml, I have made the following entries:
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Struts-2%3A-Multiple-methods-in-an-action-Class-tp14666539p14671323.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2: Multiple methods in an action Class
Posted by Ted Husted <hu...@apache.org>.
What happens if you use a method name other than "do".
There's actually a feature in Struts 2 where we can name a method
"doDefault" and then refer to it as "default" elsewhere. Naming a
method "do" might be confusing.
HTH, Ted
* <http://www.StrutsMentor.com/>
On Jan 7, 2008 9:11 AM, zuquirio <zu...@gmail.com> wrote:
>
> Hi,
> I've a strange bug. I create an action class with three methods: view(),
> check(), do(). These three methods are in one class. In my
> struts-config.xml, I have made the following entries:
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org