You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mounir Benzid <mb...@meetingmasters.de> on 2012/03/14 20:09:21 UTC
paramsPrepareParamsStack-prepare-method problem
My problem is the id is always null.
First I thought it could be b/c of the way the defaultStack is set up so
I switched to paramsPrepareParamsStack, yet the problem still remains.
Any ideas on how to obtain the id from the request?
Thanks!
Mounir
@Namespace("/public")
public class PersonCRUDAction implements Preparable {
private Long id;
@Action("blah1/{id}/blah2")
public void execute() {
... /* crud the person */
}
public Long getId() { return id;}
public void setId(Long id) {this.id=id}
@Override
public void prepare() throws Exception {
Person peron;
if (id!=null)
person = personManager.loadById(id);
else
throw new NullArgumentException("id");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: paramsPrepareParamsStack-prepare-method problem
Posted by Mounir Benzid <mb...@meetingmasters.de>.
Loosely based on the paramsPrepareParams interceptor I found this
interceptor configuration to solve my problem
The params interceptor fires once before the prepare interceptor. So far
there're no side effects
I'm not sure why the paramsPrepareParams
<interceptor-stack name="myParamsPrepareParamsStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="params"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel</param>
</interceptor-ref>
</interceptor-stack>
<interceptor-stack name="paramsPrepareParamsStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
</interceptor-ref>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
</interceptor-stack>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: paramsPrepareParamsStack-prepare-method problem
Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 14.03.2012 21:21, schrieb Dave Newton:
> And you've set the other referenced properties appropriately?
Well, here are my settings....
<!-- http://struts.apache.org/2.2.3/docs/wildcard-mappings.html -->
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.patternMatcher" value="regex" />
<!-- http://struts.apache.org/2.2.3/docs/convention-plugin.html -->
<constant name="struts.convention.classes.reload" value="true" />
<constant name="struts.convention.default.parent.package"
value="myapp-common" />
<constant name="struts.action.extension" value=",action"/>
<constant name="struts.devMode" value="true"/>
I double checked my code.... there seems nothing wrong with the pattern
matching in general. For instance when I request the url
/namespace/123/import matching the annotated pattern
"{id:[0-9]+}/import" the right action is executed and the id field is
populated accordingly.
Only the prepare method fails in this regard.
cheers
Mounir
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: paramsPrepareParamsStack-prepare-method problem
Posted by Dave Newton <da...@gmail.com>.
And you've set the other referenced properties appropriately?
On Wed, Mar 14, 2012 at 3:17 PM, Mounir Benzid <mb...@meetingmasters.de> wrote:
>
>
> <constant name="struts.patternMatcher" value="regex" />
>
> Mounir
>
> Am 14.03.2012 20:12, schrieb Dave Newton:
>
>> Are you actually using the `namedVariable` pattern matcher?
>>
>> http://struts.apache.org/2.x/**docs/wildcard-mappings.html#**
>> WildcardMappings-**Parametersinnamespaces<http://struts.apache.org/2.x/docs/wildcard-mappings.html#WildcardMappings-Parametersinnamespaces>
>>
>> Dave
>>
>> On Wed, Mar 14, 2012 at 3:09 PM, Mounir Benzid<mb...@meetingmasters.de>
>> wrote:
>>
>> My problem is the id is always null.
>>>
>>> First I thought it could be b/c of the way the defaultStack is set up so
>>> I
>>> switched to paramsPrepareParamsStack, yet the problem still remains.
>>>
>>> Any ideas on how to obtain the id from the request?
>>>
>>> Thanks!
>>> Mounir
>>>
>>> @Namespace("/public")
>>> public class PersonCRUDAction implements Preparable {
>>>
>>> private Long id;
>>>
>>> @Action("blah1/{id}/blah2")
>>> public void execute() {
>>> ... /* crud the person */
>>> }
>>>
>>> public Long getId() { return id;}
>>> public void setId(Long id) {this.id=id}
>>>
>>> @Override
>>> public void prepare() throws Exception {
>>>
>>> Person peron;
>>> if (id!=null)
>>> person = personManager.loadById(id);
>>> else
>>> throw new NullArgumentException("id");
>>> }
>>>
>>> }
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.**apac**he.org<http://apache.org>
>>> <us...@struts.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>
> --
> Mounir Benzid
> Systementwickler / EDV
>
> meetingmasters.de
> meetings meisterhaft managen
>
> · Unabhängige Vermittlung von Tagungshotels
> · Online-**Hotelreservierungssystem zur Integration in die
> Veranstaltungs-Webseite
> · Webbasiertes Veranstaltungs- und Teilnehmermanagement
> · E-Procurement für den Tagungshoteleinkauf
> · Webbasierte Anfrage und Verhandlung von Firmenraten
>
> Max-Planck-Straße 22
> D-54296 Trier
>
> fon +49 (0)651-145789-38
> fax +49 (0)651-145789-20
>
> www.meetingmasters.de
> mb@meetingmasters.de
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: paramsPrepareParamsStack-prepare-method problem
Posted by Mounir Benzid <mb...@meetingmasters.de>.
<constant name="struts.patternMatcher" value="regex" />
Mounir
Am 14.03.2012 20:12, schrieb Dave Newton:
> Are you actually using the `namedVariable` pattern matcher?
>
> http://struts.apache.org/2.x/docs/wildcard-mappings.html#WildcardMappings-Parametersinnamespaces
>
> Dave
>
> On Wed, Mar 14, 2012 at 3:09 PM, Mounir Benzid<mb...@meetingmasters.de> wrote:
>
>> My problem is the id is always null.
>>
>> First I thought it could be b/c of the way the defaultStack is set up so I
>> switched to paramsPrepareParamsStack, yet the problem still remains.
>>
>> Any ideas on how to obtain the id from the request?
>>
>> Thanks!
>> Mounir
>>
>> @Namespace("/public")
>> public class PersonCRUDAction implements Preparable {
>>
>> private Long id;
>>
>> @Action("blah1/{id}/blah2")
>> public void execute() {
>> ... /* crud the person */
>> }
>>
>> public Long getId() { return id;}
>> public void setId(Long id) {this.id=id}
>>
>> @Override
>> public void prepare() throws Exception {
>>
>> Person peron;
>> if (id!=null)
>> person = personManager.loadById(id);
>> else
>> throw new NullArgumentException("id");
>> }
>>
>> }
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
--
Mounir Benzid
Systementwickler / EDV
meetingmasters.de
meetings meisterhaft managen
· Unabhängige Vermittlung von Tagungshotels
· Online-Hotelreservierungssystem zur Integration in die Veranstaltungs-Webseite
· Webbasiertes Veranstaltungs- und Teilnehmermanagement
· E-Procurement für den Tagungshoteleinkauf
· Webbasierte Anfrage und Verhandlung von Firmenraten
Max-Planck-Straße 22
D-54296 Trier
fon +49 (0)651-145789-38
fax +49 (0)651-145789-20
www.meetingmasters.de
mb@meetingmasters.de
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: paramsPrepareParamsStack-prepare-method problem
Posted by Dave Newton <da...@gmail.com>.
Are you actually using the `namedVariable` pattern matcher?
http://struts.apache.org/2.x/docs/wildcard-mappings.html#WildcardMappings-Parametersinnamespaces
Dave
On Wed, Mar 14, 2012 at 3:09 PM, Mounir Benzid <mb...@meetingmasters.de> wrote:
>
> My problem is the id is always null.
>
> First I thought it could be b/c of the way the defaultStack is set up so I
> switched to paramsPrepareParamsStack, yet the problem still remains.
>
> Any ideas on how to obtain the id from the request?
>
> Thanks!
> Mounir
>
> @Namespace("/public")
> public class PersonCRUDAction implements Preparable {
>
> private Long id;
>
> @Action("blah1/{id}/blah2")
> public void execute() {
> ... /* crud the person */
> }
>
> public Long getId() { return id;}
> public void setId(Long id) {this.id=id}
>
> @Override
> public void prepare() throws Exception {
>
> Person peron;
> if (id!=null)
> person = personManager.loadById(id);
> else
> throw new NullArgumentException("id");
> }
>
> }
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>