You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2009/02/04 17:34:48 UTC

Re: 2.1.6 - 2.0.11 - ResultConfig -- will a custom Result class work?

 From the ActionConfig.Builder#build() javadoc:

"The builder for this object.  An instance of this object is the only way to 
construct a new instance.  The purpose is to enforce the immutability of the 
object.  The methods are structured in a way to support chaining. After
setting any values you need, call the {@link #build()} method to create the object."


I assume there was some issue behind the scenes with robustness.

For the long term it would be good to have an official struts method to set the 
HTTP params programmatically.

What I'm going to do now is code up a Result class to extend 
ServletActionRedirectResult - someone give me a shout if I'm barking up the 
wrong tree.

Thanks
Adam


Adam Hardy (struts) on 04/02/09 15:16, wrote:
> I'm prevented from adding my redirect parameter programmatically with 2.1.6!
> 
> Look:
> 
> Map<String, ResultConfig> resultsMap =
>     ServletActionContext.getActionContext(getRequest())
>         .getActionInvocation().getProxy().getConfig().getResults();
> ResultConfig config = resultsMap.get(resultName);
> Map<String, String> params = config.getParams();
> params.put(paramName, paramValue.toString());
>  
> causes:
> java.lang.UnsupportedOperationException
> 	at java.util.Collections$UnmodifiableMap.put(Collections.java:1285)
> 
> Or am I jumping to conclusions again?
> 
> Adam
> 
> --- original message author="Musachy Barroso"
>> I think just need to pass a string, instead of an object in the value
> param.
>> musachy
>>
>> On Mon, Jan 26, 2009 at 10:37 AM, Adam Hardy wrote:
>> Hi,
>>
>> got a compilation error after upgrading from 2.0.11 to 2.1.6 due to
>> changes
>> in com.opensymphony.xwork2.config.entities.ResultConfig
>>
>> I am doing this:
>>
>>    public boolean addRedirectParameter(String resultName, String
>> paramName,
>>        Object paramValue)
>>    {
>>        Map<String, ResultConfig> resultsMap =
>>            ServletActionContext.getActionContext(getRequest())
>>                .getActionInvocation().getProxy().getConfig().getResults();
>>        ResultConfig config = resultsMap.get(resultName);
>>        if (config == null)
>>        {
>>            return false;
>>        }
>>        else
>>        {
>>            config.addParam(paramName, paramValue);  // 2.1.6 COMPILE ERROR
>>            return true;
>>        }
>>    }
>>
>>
>> which I can call in my actions in order to put another parameter onto the
>> redirect URL of my result.
>>
>> In 2.1.6, ResultConfig has no addParam() method anymore.
>>
>> After checking the upgrade troubleshooting guide and the user lists, it 
>> seems nobody else is suffering from this problem. Could somebody give me an
>>  idea how to deal with this?


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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Dave Newton <ne...@yahoo.com>.
Adam Hardy wrote:
>> What are the additional testing requirements? The returned result is a 
>> string, the parameters used in the result config are strings--what's 
>> left?
> 
> The unit test must additionally set up struts to be aware of the config.

Not if you're testing the action itself: check to see if the result 
string is what you expect and the exposed config strings are also what 
you expect.

If you're testing the configuration mechanism of Struts 2 itself, 
sure... but that cross the boundary of what I want to test in the app 
test code: if my action runs and I get the expected action properties 
when it's done I'm satisfied my action has run correctly.

At best I'd do client-focused integration testing (for example, by 
driving a browser) to make sure the front-end contains what I expect it 
to, incidentally testing Struts 2 in the process--but my goal isn't to 
re-test Struts 2.

It's possible I'm still not understanding what you're saying.

> Regarding JSTL vs OGNL, again, the simplicity of JSTL is fine. When you 
> need something complex, write a taglib function for it - generally it's 
> easier to read in the JSP and the taglib code is testable.

We'll have to agree to disagree--I hate being hamstrung in the view.

> Just my PoV - coming from a generalist in coding right across the GUI / 
> MVC / Java / DB stack, rather than as a front-end specialist.

I'm an ex-AI and embedded systems/device driver developer--I've been 
nearly as far from the front-end as is possible to get. But when I'm 
forced to deal with it I don't appreciate not having the same 
expressiveness as the powerful languages I'm used to.

Dave


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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Dave Newton on 05/02/09 16:47, wrote:
> Adam Hardy wrote:
>> Tell you the truth, I don't really dig the idea of having to specify 
>> parameter in config file like that - I think it adds another thing 
>> that can go wrong when you're refactoring. And it also needs special 
>> testing requirements.
> 
> What are the additional testing requirements? The returned result is a 
> string, the parameters used in the result config are strings--what's left?

The unit test must additionally set up struts to be aware of the config.

Junit4 / easymock to test the actions without any reference to the config 
doesn't need that.

Perhaps it's trivial although I doubt it. The concept of putting that action 
parameter into the config when it's not an initialization param blurs boundaries 
and bends the KISS approach too far.

Regarding JSTL vs OGNL, again, the simplicity of JSTL is fine. When you need 
something complex, write a taglib function for it - generally it's easier to 
read in the JSP and the taglib code is testable.

HTTP and HTML is so messy even on its own, I think it's best to keep it as 
simple as possible.

Just my PoV - coming from a generalist in coding right across the GUI / MVC / 
Java / DB stack, rather than as a front-end specialist.

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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Dave Newton <ne...@yahoo.com>.
Adam Hardy wrote:
> Tell you the truth, I don't really dig the idea of having to specify 
> parameter in config file like that - I think it adds another thing that 
> can go wrong when you're refactoring. And it also needs special testing 
> requirements.

What are the additional testing requirements? The returned result is a 
string, the parameters used in the result config are strings--what's left?

> In fact OGNL is pretty much persona non grata around here.

Too bad; it's substantially more powerful than JSP EL, although I'll be 
happy to try out MVEL support for the speed boost.

> I can't see that my requirement is such an exceptional case.

FWIW across a half-dozen S2 apps I haven't needed to do anything like 
that, so it can't be *super* common--these were non-trivial apps.

Not saying it shouldn't or can't change, just still a little fuzzy on 
why it should.

Dave


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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Tell you the truth, I don't really dig the idea of having to specify parameter 
in config file like that - I think it adds another thing that can go wrong when 
you're refactoring. And it also needs special testing requirements.

In fact OGNL is pretty much persona non grata around here.

I can't see that my requirement is such an exceptional case. The method I ended 
up writing would be fit well in the ActionSupport class.

So anyway after a coffee and a fresh look at the ActionInvocation mechanism, I 
worked out what to do programmatically without jumping through any hoops, so I'm 
sorted now - at least until the next big version number increment :(



Musachy Barroso on 05/02/09 14:10, wrote:
> If all you want to do is pass a parameter, then why don't you make it
> available in your action and then juts pass it to the result using
> OGNL? See this:
> 
> http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html
> 
> Overall it is not a good idea to use internal Struts classes, as they
> can change, and they often do.
> 
> musachy
> 
> 
> On Thu, Feb 5, 2009 at 4:28 AM, Adam Hardy
> <ah...@cyberspaceroad.com> wrote:
>> Hi Musachy,
>>
>> I'm adding it in my action.
>>
>> That's why it gets overwritten - because when Action's method returns,
>> struts calls for the Result, presumably re-creating it even though it's
>> there.
>>
>> I don't understand why because there appears to be the code to provide an
>> existing Result rather than recreating it, I just haven't delved as far into
>> the underbelly of the struts mechanism calling the
>> ActionInvocation#getResult().
>>
>>
>>
>> Musachy Barroso on 04/02/09 19:07, wrote:
>>> Lets take one step back, are you adding this param in an interceptor
>>> or in your action?
>>>
>>> musachy
>>>
>>> On Wed, Feb 4, 2009 at 1:49 PM, Adam Hardy
>>> <ah...@cyberspaceroad.com> wrote:
>>>> Now that 2.1.6 won't let me add to the resultConfig to add my redirect
>>>> httpParameters myself, I figured I'd have to obtain the actual Result
>>>> object.
>>>>
>>>> The way that DefaultActionInvocation is programmed to do this though
>>>> makes
>>>> it impossible, despite the Javadocs explicitly stating otherwise e.g.
>>>>
>>>> http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionInvocation.html#getResult()
>>>>
>>>> Then I can't call the create result method since it's not on the
>>>> interface.
>>>>
>>>> Even when I cast the ActionInvocation and call the create method and
>>>> faithfully add my redirect parameter, the result gets overwritten later
>>>> anyway.
>>>>
>>>> It looks like I must downgrade from here - unless anyone can think of
>>>> another way of programmatically adding the parameters to the redirect
>>>> URL.
>>>>
>>>>
>>>> Adam
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Adam Hardy on 04/02/09 16:34, wrote:
>>>>>  From the ActionConfig.Builder#build() javadoc:
>>>>>
>>>>> "The builder for this object.  An instance of this object is the only
>>>>> way
>>>>> to construct a new instance.  The purpose is to enforce the immutability
>>>>> of
>>>>> the object.  The methods are structured in a way to support chaining.
>>>>> After
>>>>> setting any values you need, call the {@link #build()} method to create
>>>>> the object."
>>>>>
>>>>>
>>>>> I assume there was some issue behind the scenes with robustness.
>>>>>
>>>>> For the long term it would be good to have an official struts method to
>>>>> set the HTTP params programmatically.
>>>>>
>>>>> What I'm going to do now is code up a Result class to extend
>>>>> ServletActionRedirectResult - someone give me a shout if I'm barking up
>>>>> the
>>>>> wrong tree.
>>>>>
>>>>> Thanks
>>>>> Adam
>>>>>
>>>>>
>>>>> Adam Hardy (struts) on 04/02/09 15:16, wrote:
>>>>>> I'm prevented from adding my redirect parameter programmatically with
>>>>>> 2.1.6!
>>>>>>
>>>>>> Look:
>>>>>>
>>>>>> Map<String, ResultConfig> resultsMap =
>>>>>>   ServletActionContext.getActionContext(getRequest())
>>>>>>       .getActionInvocation().getProxy().getConfig().getResults();
>>>>>> ResultConfig config = resultsMap.get(resultName);
>>>>>> Map<String, String> params = config.getParams();
>>>>>> params.put(paramName, paramValue.toString());
>>>>>>  causes:
>>>>>> java.lang.UnsupportedOperationException
>>>>>>   at java.util.Collections$UnmodifiableMap.put(Collections.java:1285)
>>>>>>
>>>>>> Or am I jumping to conclusions again?
>>>>>>
>>>>>> Adam
>>>>>>
>>>>>> --- original message author="Musachy Barroso"
>>>>>>> I think just need to pass a string, instead of an object in the value
>>>>>> param.
>>>>>>> musachy
>>>>>>>
>>>>>>> On Mon, Jan 26, 2009 at 10:37 AM, Adam Hardy wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> got a compilation error after upgrading from 2.0.11 to 2.1.6 due to
>>>>>>> changes
>>>>>>> in com.opensymphony.xwork2.config.entities.ResultConfig
>>>>>>>
>>>>>>> I am doing this:
>>>>>>>
>>>>>>>  public boolean addRedirectParameter(String resultName, String
>>>>>>> paramName,
>>>>>>>      Object paramValue)
>>>>>>>  {
>>>>>>>      Map<String, ResultConfig> resultsMap =
>>>>>>>          ServletActionContext.getActionContext(getRequest())
>>>>>>>
>>>>>>> .getActionInvocation().getProxy().getConfig().getResults();
>>>>>>>      ResultConfig config = resultsMap.get(resultName);
>>>>>>>      if (config == null)
>>>>>>>      {
>>>>>>>          return false;
>>>>>>>      }
>>>>>>>      else
>>>>>>>      {
>>>>>>>          config.addParam(paramName, paramValue);  // 2.1.6 COMPILE
>>>>>>> ERROR
>>>>>>>          return true;
>>>>>>>      }
>>>>>>>  }
>>>>>>>
>>>>>>>
>>>>>>> which I can call in my actions in order to put another parameter onto
>>>>>>> the
>>>>>>> redirect URL of my result.
>>>>>>>
>>>>>>> In 2.1.6, ResultConfig has no addParam() method anymore.
>>>>>>>
>>>>>>> After checking the upgrade troubleshooting guide and the user lists,
>>>>>>> it
>>>>>>> seems nobody else is suffering from this problem. Could somebody give
>>>>>>> me an
>>>>>>>  idea how to deal with this?


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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Musachy Barroso <mu...@gmail.com>.
If all you want to do is pass a parameter, then why don't you make it
available in your action and then juts pass it to the result using
OGNL? See this:

http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html

Overall it is not a good idea to use internal Struts classes, as they
can change, and they often do.

musachy


On Thu, Feb 5, 2009 at 4:28 AM, Adam Hardy
<ah...@cyberspaceroad.com> wrote:
> Hi Musachy,
>
> I'm adding it in my action.
>
> That's why it gets overwritten - because when Action's method returns,
> struts calls for the Result, presumably re-creating it even though it's
> there.
>
> I don't understand why because there appears to be the code to provide an
> existing Result rather than recreating it, I just haven't delved as far into
> the underbelly of the struts mechanism calling the
> ActionInvocation#getResult().
>
>
>
> Musachy Barroso on 04/02/09 19:07, wrote:
>>
>> Lets take one step back, are you adding this param in an interceptor
>> or in your action?
>>
>> musachy
>>
>> On Wed, Feb 4, 2009 at 1:49 PM, Adam Hardy
>> <ah...@cyberspaceroad.com> wrote:
>>>
>>> Now that 2.1.6 won't let me add to the resultConfig to add my redirect
>>> httpParameters myself, I figured I'd have to obtain the actual Result
>>> object.
>>>
>>> The way that DefaultActionInvocation is programmed to do this though
>>> makes
>>> it impossible, despite the Javadocs explicitly stating otherwise e.g.
>>>
>>> http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionInvocation.html#getResult()
>>>
>>> Then I can't call the create result method since it's not on the
>>> interface.
>>>
>>> Even when I cast the ActionInvocation and call the create method and
>>> faithfully add my redirect parameter, the result gets overwritten later
>>> anyway.
>>>
>>> It looks like I must downgrade from here - unless anyone can think of
>>> another way of programmatically adding the parameters to the redirect
>>> URL.
>>>
>>>
>>> Adam
>>>
>>>
>>>
>>>
>>>
>>> Adam Hardy on 04/02/09 16:34, wrote:
>>>>
>>>>  From the ActionConfig.Builder#build() javadoc:
>>>>
>>>> "The builder for this object.  An instance of this object is the only
>>>> way
>>>> to construct a new instance.  The purpose is to enforce the immutability
>>>> of
>>>> the object.  The methods are structured in a way to support chaining.
>>>> After
>>>> setting any values you need, call the {@link #build()} method to create
>>>> the object."
>>>>
>>>>
>>>> I assume there was some issue behind the scenes with robustness.
>>>>
>>>> For the long term it would be good to have an official struts method to
>>>> set the HTTP params programmatically.
>>>>
>>>> What I'm going to do now is code up a Result class to extend
>>>> ServletActionRedirectResult - someone give me a shout if I'm barking up
>>>> the
>>>> wrong tree.
>>>>
>>>> Thanks
>>>> Adam
>>>>
>>>>
>>>> Adam Hardy (struts) on 04/02/09 15:16, wrote:
>>>>>
>>>>> I'm prevented from adding my redirect parameter programmatically with
>>>>> 2.1.6!
>>>>>
>>>>> Look:
>>>>>
>>>>> Map<String, ResultConfig> resultsMap =
>>>>>   ServletActionContext.getActionContext(getRequest())
>>>>>       .getActionInvocation().getProxy().getConfig().getResults();
>>>>> ResultConfig config = resultsMap.get(resultName);
>>>>> Map<String, String> params = config.getParams();
>>>>> params.put(paramName, paramValue.toString());
>>>>>  causes:
>>>>> java.lang.UnsupportedOperationException
>>>>>   at java.util.Collections$UnmodifiableMap.put(Collections.java:1285)
>>>>>
>>>>> Or am I jumping to conclusions again?
>>>>>
>>>>> Adam
>>>>>
>>>>> --- original message author="Musachy Barroso"
>>>>>>
>>>>>> I think just need to pass a string, instead of an object in the value
>>>>>
>>>>> param.
>>>>>>
>>>>>> musachy
>>>>>>
>>>>>> On Mon, Jan 26, 2009 at 10:37 AM, Adam Hardy wrote:
>>>>>> Hi,
>>>>>>
>>>>>> got a compilation error after upgrading from 2.0.11 to 2.1.6 due to
>>>>>> changes
>>>>>> in com.opensymphony.xwork2.config.entities.ResultConfig
>>>>>>
>>>>>> I am doing this:
>>>>>>
>>>>>>  public boolean addRedirectParameter(String resultName, String
>>>>>> paramName,
>>>>>>      Object paramValue)
>>>>>>  {
>>>>>>      Map<String, ResultConfig> resultsMap =
>>>>>>          ServletActionContext.getActionContext(getRequest())
>>>>>>
>>>>>> .getActionInvocation().getProxy().getConfig().getResults();
>>>>>>      ResultConfig config = resultsMap.get(resultName);
>>>>>>      if (config == null)
>>>>>>      {
>>>>>>          return false;
>>>>>>      }
>>>>>>      else
>>>>>>      {
>>>>>>          config.addParam(paramName, paramValue);  // 2.1.6 COMPILE
>>>>>> ERROR
>>>>>>          return true;
>>>>>>      }
>>>>>>  }
>>>>>>
>>>>>>
>>>>>> which I can call in my actions in order to put another parameter onto
>>>>>> the
>>>>>> redirect URL of my result.
>>>>>>
>>>>>> In 2.1.6, ResultConfig has no addParam() method anymore.
>>>>>>
>>>>>> After checking the upgrade troubleshooting guide and the user lists,
>>>>>> it
>>>>>> seems nobody else is suffering from this problem. Could somebody give
>>>>>> me an
>>>>>>  idea how to deal with this?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Musachy,

I'm adding it in my action.

That's why it gets overwritten - because when Action's method returns, struts 
calls for the Result, presumably re-creating it even though it's there.

I don't understand why because there appears to be the code to provide an 
existing Result rather than recreating it, I just haven't delved as far into the 
underbelly of the struts mechanism calling the ActionInvocation#getResult().



Musachy Barroso on 04/02/09 19:07, wrote:
> Lets take one step back, are you adding this param in an interceptor
> or in your action?
> 
> musachy
> 
> On Wed, Feb 4, 2009 at 1:49 PM, Adam Hardy
> <ah...@cyberspaceroad.com> wrote:
>> Now that 2.1.6 won't let me add to the resultConfig to add my redirect
>> httpParameters myself, I figured I'd have to obtain the actual Result
>> object.
>>
>> The way that DefaultActionInvocation is programmed to do this though makes
>> it impossible, despite the Javadocs explicitly stating otherwise e.g.
>> http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionInvocation.html#getResult()
>>
>> Then I can't call the create result method since it's not on the interface.
>>
>> Even when I cast the ActionInvocation and call the create method and
>> faithfully add my redirect parameter, the result gets overwritten later
>> anyway.
>>
>> It looks like I must downgrade from here - unless anyone can think of
>> another way of programmatically adding the parameters to the redirect URL.
>>
>>
>> Adam
>>
>>
>>
>>
>>
>> Adam Hardy on 04/02/09 16:34, wrote:
>>>  From the ActionConfig.Builder#build() javadoc:
>>>
>>> "The builder for this object.  An instance of this object is the only way
>>> to construct a new instance.  The purpose is to enforce the immutability of
>>> the object.  The methods are structured in a way to support chaining. After
>>> setting any values you need, call the {@link #build()} method to create
>>> the object."
>>>
>>>
>>> I assume there was some issue behind the scenes with robustness.
>>>
>>> For the long term it would be good to have an official struts method to
>>> set the HTTP params programmatically.
>>>
>>> What I'm going to do now is code up a Result class to extend
>>> ServletActionRedirectResult - someone give me a shout if I'm barking up the
>>> wrong tree.
>>>
>>> Thanks
>>> Adam
>>>
>>>
>>> Adam Hardy (struts) on 04/02/09 15:16, wrote:
>>>> I'm prevented from adding my redirect parameter programmatically with
>>>> 2.1.6!
>>>>
>>>> Look:
>>>>
>>>> Map<String, ResultConfig> resultsMap =
>>>>    ServletActionContext.getActionContext(getRequest())
>>>>        .getActionInvocation().getProxy().getConfig().getResults();
>>>> ResultConfig config = resultsMap.get(resultName);
>>>> Map<String, String> params = config.getParams();
>>>> params.put(paramName, paramValue.toString());
>>>>  causes:
>>>> java.lang.UnsupportedOperationException
>>>>    at java.util.Collections$UnmodifiableMap.put(Collections.java:1285)
>>>>
>>>> Or am I jumping to conclusions again?
>>>>
>>>> Adam
>>>>
>>>> --- original message author="Musachy Barroso"
>>>>> I think just need to pass a string, instead of an object in the value
>>>> param.
>>>>> musachy
>>>>>
>>>>> On Mon, Jan 26, 2009 at 10:37 AM, Adam Hardy wrote:
>>>>> Hi,
>>>>>
>>>>> got a compilation error after upgrading from 2.0.11 to 2.1.6 due to
>>>>> changes
>>>>> in com.opensymphony.xwork2.config.entities.ResultConfig
>>>>>
>>>>> I am doing this:
>>>>>
>>>>>   public boolean addRedirectParameter(String resultName, String
>>>>> paramName,
>>>>>       Object paramValue)
>>>>>   {
>>>>>       Map<String, ResultConfig> resultsMap =
>>>>>           ServletActionContext.getActionContext(getRequest())
>>>>>
>>>>> .getActionInvocation().getProxy().getConfig().getResults();
>>>>>       ResultConfig config = resultsMap.get(resultName);
>>>>>       if (config == null)
>>>>>       {
>>>>>           return false;
>>>>>       }
>>>>>       else
>>>>>       {
>>>>>           config.addParam(paramName, paramValue);  // 2.1.6 COMPILE
>>>>> ERROR
>>>>>           return true;
>>>>>       }
>>>>>   }
>>>>>
>>>>>
>>>>> which I can call in my actions in order to put another parameter onto
>>>>> the
>>>>> redirect URL of my result.
>>>>>
>>>>> In 2.1.6, ResultConfig has no addParam() method anymore.
>>>>>
>>>>> After checking the upgrade troubleshooting guide and the user lists, it
>>>>> seems nobody else is suffering from this problem. Could somebody give me an
>>>>>  idea how to deal with this?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> 


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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Musachy Barroso <mu...@gmail.com>.
Lets take one step back, are you adding this param in an interceptor
or in your action?

musachy

On Wed, Feb 4, 2009 at 1:49 PM, Adam Hardy
<ah...@cyberspaceroad.com> wrote:
> Now that 2.1.6 won't let me add to the resultConfig to add my redirect
> httpParameters myself, I figured I'd have to obtain the actual Result
> object.
>
> The way that DefaultActionInvocation is programmed to do this though makes
> it impossible, despite the Javadocs explicitly stating otherwise e.g.
> http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionInvocation.html#getResult()
>
> Then I can't call the create result method since it's not on the interface.
>
> Even when I cast the ActionInvocation and call the create method and
> faithfully add my redirect parameter, the result gets overwritten later
> anyway.
>
> It looks like I must downgrade from here - unless anyone can think of
> another way of programmatically adding the parameters to the redirect URL.
>
>
> Adam
>
>
>
>
>
> Adam Hardy on 04/02/09 16:34, wrote:
>>
>>  From the ActionConfig.Builder#build() javadoc:
>>
>> "The builder for this object.  An instance of this object is the only way
>> to construct a new instance.  The purpose is to enforce the immutability of
>> the object.  The methods are structured in a way to support chaining. After
>> setting any values you need, call the {@link #build()} method to create
>> the object."
>>
>>
>> I assume there was some issue behind the scenes with robustness.
>>
>> For the long term it would be good to have an official struts method to
>> set the HTTP params programmatically.
>>
>> What I'm going to do now is code up a Result class to extend
>> ServletActionRedirectResult - someone give me a shout if I'm barking up the
>> wrong tree.
>>
>> Thanks
>> Adam
>>
>>
>> Adam Hardy (struts) on 04/02/09 15:16, wrote:
>>>
>>> I'm prevented from adding my redirect parameter programmatically with
>>> 2.1.6!
>>>
>>> Look:
>>>
>>> Map<String, ResultConfig> resultsMap =
>>>    ServletActionContext.getActionContext(getRequest())
>>>        .getActionInvocation().getProxy().getConfig().getResults();
>>> ResultConfig config = resultsMap.get(resultName);
>>> Map<String, String> params = config.getParams();
>>> params.put(paramName, paramValue.toString());
>>>  causes:
>>> java.lang.UnsupportedOperationException
>>>    at java.util.Collections$UnmodifiableMap.put(Collections.java:1285)
>>>
>>> Or am I jumping to conclusions again?
>>>
>>> Adam
>>>
>>> --- original message author="Musachy Barroso"
>>>>
>>>> I think just need to pass a string, instead of an object in the value
>>>
>>> param.
>>>>
>>>> musachy
>>>>
>>>> On Mon, Jan 26, 2009 at 10:37 AM, Adam Hardy wrote:
>>>> Hi,
>>>>
>>>> got a compilation error after upgrading from 2.0.11 to 2.1.6 due to
>>>> changes
>>>> in com.opensymphony.xwork2.config.entities.ResultConfig
>>>>
>>>> I am doing this:
>>>>
>>>>   public boolean addRedirectParameter(String resultName, String
>>>> paramName,
>>>>       Object paramValue)
>>>>   {
>>>>       Map<String, ResultConfig> resultsMap =
>>>>           ServletActionContext.getActionContext(getRequest())
>>>>
>>>> .getActionInvocation().getProxy().getConfig().getResults();
>>>>       ResultConfig config = resultsMap.get(resultName);
>>>>       if (config == null)
>>>>       {
>>>>           return false;
>>>>       }
>>>>       else
>>>>       {
>>>>           config.addParam(paramName, paramValue);  // 2.1.6 COMPILE
>>>> ERROR
>>>>           return true;
>>>>       }
>>>>   }
>>>>
>>>>
>>>> which I can call in my actions in order to put another parameter onto
>>>> the
>>>> redirect URL of my result.
>>>>
>>>> In 2.1.6, ResultConfig has no addParam() method anymore.
>>>>
>>>> After checking the upgrade troubleshooting guide and the user lists, it
>>>> seems nobody else is suffering from this problem. Could somebody give me an
>>>>  idea how to deal with this?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: 2.1.6 slams a few doors shut, doesn't it?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Now that 2.1.6 won't let me add to the resultConfig to add my redirect 
httpParameters myself, I figured I'd have to obtain the actual Result object.

The way that DefaultActionInvocation is programmed to do this though makes it 
impossible, despite the Javadocs explicitly stating otherwise e.g. 
http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionInvocation.html#getResult()

Then I can't call the create result method since it's not on the interface.

Even when I cast the ActionInvocation and call the create method and faithfully 
add my redirect parameter, the result gets overwritten later anyway.

It looks like I must downgrade from here - unless anyone can think of another 
way of programmatically adding the parameters to the redirect URL.


Adam





Adam Hardy on 04/02/09 16:34, wrote:
>  From the ActionConfig.Builder#build() javadoc:
> 
> "The builder for this object.  An instance of this object is the only 
> way to construct a new instance.  The purpose is to enforce the 
> immutability of the object.  The methods are structured in a way to 
> support chaining. After
> setting any values you need, call the {@link #build()} method to create 
> the object."
> 
> 
> I assume there was some issue behind the scenes with robustness.
> 
> For the long term it would be good to have an official struts method to 
> set the HTTP params programmatically.
> 
> What I'm going to do now is code up a Result class to extend 
> ServletActionRedirectResult - someone give me a shout if I'm barking up 
> the wrong tree.
> 
> Thanks
> Adam
> 
> 
> Adam Hardy (struts) on 04/02/09 15:16, wrote:
>> I'm prevented from adding my redirect parameter programmatically with 
>> 2.1.6!
>>
>> Look:
>>
>> Map<String, ResultConfig> resultsMap =
>>     ServletActionContext.getActionContext(getRequest())
>>         .getActionInvocation().getProxy().getConfig().getResults();
>> ResultConfig config = resultsMap.get(resultName);
>> Map<String, String> params = config.getParams();
>> params.put(paramName, paramValue.toString());
>>  
>> causes:
>> java.lang.UnsupportedOperationException
>>     at java.util.Collections$UnmodifiableMap.put(Collections.java:1285)
>>
>> Or am I jumping to conclusions again?
>>
>> Adam
>>
>> --- original message author="Musachy Barroso"
>>> I think just need to pass a string, instead of an object in the value
>> param.
>>> musachy
>>>
>>> On Mon, Jan 26, 2009 at 10:37 AM, Adam Hardy wrote:
>>> Hi,
>>>
>>> got a compilation error after upgrading from 2.0.11 to 2.1.6 due to
>>> changes
>>> in com.opensymphony.xwork2.config.entities.ResultConfig
>>>
>>> I am doing this:
>>>
>>>    public boolean addRedirectParameter(String resultName, String
>>> paramName,
>>>        Object paramValue)
>>>    {
>>>        Map<String, ResultConfig> resultsMap =
>>>            ServletActionContext.getActionContext(getRequest())
>>>                
>>> .getActionInvocation().getProxy().getConfig().getResults();
>>>        ResultConfig config = resultsMap.get(resultName);
>>>        if (config == null)
>>>        {
>>>            return false;
>>>        }
>>>        else
>>>        {
>>>            config.addParam(paramName, paramValue);  // 2.1.6 COMPILE 
>>> ERROR
>>>            return true;
>>>        }
>>>    }
>>>
>>>
>>> which I can call in my actions in order to put another parameter onto 
>>> the
>>> redirect URL of my result.
>>>
>>> In 2.1.6, ResultConfig has no addParam() method anymore.
>>>
>>> After checking the upgrade troubleshooting guide and the user lists, 
>>> it seems nobody else is suffering from this problem. Could somebody 
>>> give me an
>>>  idea how to deal with this?


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