You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by cm132005 <cm...@gmail.com> on 2009/05/06 23:48:58 UTC

S2 - s:submit method="value" has to be hard-coded?

There is a scenario where the same submit button needs to handle three
different method calls in a dispatch action. To avoid coding the same button
three times, I tried
 
<s:submit value=" Save " method='<s:property value="methodName"/>' />
java.lang.NoSuchMethodException: com.abc.xyz.struts.ExampleDispatchAction.() 

<s:submit value=" Save " method="<%=methodName%>"/>
org.apache.jasper.JasperException: /jsp/example/exampleEdit.jsp(130,11)
According to TLD or attribute directive in tag file, attribute method does
not accept any expressions 

<s:submit value=" Save " method="<s:property value="methodName"/>"/>
org.apache.jasper.JasperException: /jsp/example/exampleEdit.jsp(132,88)
equal symbol expected 

It seems like we have to hard code the method value. Is there a better way
to handle this?
-- 
View this message in context: http://www.nabble.com/S2---s%3Asubmit-method%3D%22value%22-has-to-be-hard-coded--tp23416227p23416227.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: S2 - s:submit method="value" has to be hard-coded?

Posted by Dave Newton <ne...@yahoo.com>.
cm132005 wrote:
> That's how I have it configured but somehow the "method" doesn't seem to take
> a variable value....
> 
> <action name="*Example"  method="{1}"
> class="com.abc.xyz.struts.ExampleDispatchAction">
> 
> these throw exception:
> <s:submit value=" Save as A " method='<s:property value="methodName"/>' /> 
> <s:submit value=" Save as A " method="<%=methodName%>"/> 
> <s:submit value=" Save as A " method="<s:property value="methodName"/>"/> 
> 
> works with hard-coded values:
> <s:submit value=" Save as A " method="aSave"  />
> <s:submit value=" Save as B " method="bSave"  />
> <s:submit value=" Save as C " method="cSave"  />
> 
> May be I am missing something...

Yes; basic JSP. As in the previous message you can't arbitrarily nest 
tags--just like you can't nest elements like that in XML. See my answer 
to your other question.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: S2 - s:submit method="value" has to be hard-coded?

Posted by cm132005 <cm...@gmail.com>.
That's how I have it configured but somehow the "method" doesn't seem to take
a variable value....

<action name="*Example"  method="{1}"
class="com.abc.xyz.struts.ExampleDispatchAction">

these throw exception:
<s:submit value=" Save as A " method='<s:property value="methodName"/>' /> 
<s:submit value=" Save as A " method="<%=methodName%>"/> 
<s:submit value=" Save as A " method="<s:property value="methodName"/>"/> 

works with hard-coded values:
<s:submit value=" Save as A " method="aSave"  />
<s:submit value=" Save as B " method="bSave"  />
<s:submit value=" Save as C " method="cSave"  />

May be I am missing something...

Thanks.



mgainty wrote:
> 
> 
> I would try populating the method with a splitting of the actionname for
> applicable method
> Here, a reference to "editCrud" will call the edit method on an 
> instance of the Crud Action class. Likewise, a reference to "deleteCrud"
> will 
> call the delete method instead. 
> <action name="*Crud" class="example.Crud" method="{1}">
> 
> 
> http://struts.apache.org/2.0.14/docs/action-configuration.html
> 
> that is one solution..i am sure there are many others
> 
> HTH
> Martin Gainty 
> ______________________________________________ 
> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note
> de déni et de confidentialité
> This message is confidential. If you should not be the intended receiver,
> then we ask politely to report. Each unauthorized forwarding or
> manufacturing of a copy is inadmissible. This message serves only for the
> exchange of information and has no legal binding effect. Due to the easy
> manipulation of emails we cannot take responsibility over the the
> contents.
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie de ceci est interdite. Ce message sert à l'information seulement et
> n'aura pas n'importe quel effet légalement obligatoire. Étant donné que
> les email peuvent facilement être sujets à la manipulation, nous ne
> pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
>> Date: Wed, 6 May 2009 14:48:58 -0700
>> From: cm132005@gmail.com
>> To: user@struts.apache.org
>> Subject: S2 - s:submit method="value" has to be hard-coded?
>> 
>> 
>> There is a scenario where the same submit button needs to handle three
>> different method calls in a dispatch action. To avoid coding the same
>> button
>> three times, I tried
>>  
>> <s:submit value=" Save " method='<s:property value="methodName"/>' />
>> java.lang.NoSuchMethodException:
>> com.abc.xyz.struts.ExampleDispatchAction.() 
>> 
>> <s:submit value=" Save " method="<%=methodName%>"/>
>> org.apache.jasper.JasperException: /jsp/example/exampleEdit.jsp(130,11)
>> According to TLD or attribute directive in tag file, attribute method
>> does
>> not accept any expressions 
>> 
>> <s:submit value=" Save " method="<s:property value="methodName"/>"/>
>> org.apache.jasper.JasperException: /jsp/example/exampleEdit.jsp(132,88)
>> equal symbol expected 
>> 
>> It seems like we have to hard code the method value. Is there a better
>> way
>> to handle this?
>> -- 
>> View this message in context:
>> http://www.nabble.com/S2---s%3Asubmit-method%3D%22value%22-has-to-be-hard-coded--tp23416227p23416227.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
>> 
> 
> _________________________________________________________________
> Hotmail® goes with you. 
> http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
> 

-- 
View this message in context: http://www.nabble.com/S2---s%3Asubmit-method%3D%22value%22-has-to-be-hard-coded--tp23416227p23438629.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: S2 - s:submit method="value" has to be hard-coded?

Posted by Martin Gainty <mg...@hotmail.com>.
I would try populating the method with a splitting of the actionname for applicable method
Here, a reference to "editCrud" will call the edit method on an 
instance of the Crud Action class. Likewise, a reference to "deleteCrud" will 
call the delete method instead. 
<action name="*Crud" class="example.Crud" method="{1}">


http://struts.apache.org/2.0.14/docs/action-configuration.html

that is one solution..i am sure there are many others

HTH
Martin Gainty 
______________________________________________ 
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 6 May 2009 14:48:58 -0700
> From: cm132005@gmail.com
> To: user@struts.apache.org
> Subject: S2 - s:submit method="value" has to be hard-coded?
> 
> 
> There is a scenario where the same submit button needs to handle three
> different method calls in a dispatch action. To avoid coding the same button
> three times, I tried
>  
> <s:submit value=" Save " method='<s:property value="methodName"/>' />
> java.lang.NoSuchMethodException: com.abc.xyz.struts.ExampleDispatchAction.() 
> 
> <s:submit value=" Save " method="<%=methodName%>"/>
> org.apache.jasper.JasperException: /jsp/example/exampleEdit.jsp(130,11)
> According to TLD or attribute directive in tag file, attribute method does
> not accept any expressions 
> 
> <s:submit value=" Save " method="<s:property value="methodName"/>"/>
> org.apache.jasper.JasperException: /jsp/example/exampleEdit.jsp(132,88)
> equal symbol expected 
> 
> It seems like we have to hard code the method value. Is there a better way
> to handle this?
> -- 
> View this message in context: http://www.nabble.com/S2---s%3Asubmit-method%3D%22value%22-has-to-be-hard-coded--tp23416227p23416227.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
> 

_________________________________________________________________
Hotmail® goes with you. 
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009

Re: S2 - s:submit method="value" has to be hard-coded?

Posted by Dave Newton <ne...@yahoo.com>.
cm132005 wrote:
> Yes and that's why I think the DispatchAction was better in Struts 1. 

I don't see how--it's essentially the exact same thing, but not tied to 
the framework.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: S2 - s:submit method="value" has to be hard-coded?

Posted by cm132005 <cm...@gmail.com>.
Yes and that's why I think the DispatchAction was better in Struts 1. 


musomesa wrote:
> 
> There is bound to be some logic that determines what method the button 
> would invoke. Why not put that logic in the action method and have it call 
> appropriate helper methods? In other words move the fork from the view to
> inside 
> the action method.
> Chris
> **************Remember Mom this Mother's Day! Find a florist near you now. 
> (http://yellowpages.aol.com/search?query=florist&ncid=emlcntusyelp00000006)
> 
> 

-- 
View this message in context: http://www.nabble.com/S2---s%3Asubmit-method%3D%22value%22-has-to-be-hard-coded--tp23416227p23489168.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