Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 24 Jul 2009 20:59:18 -0000 Issue 8769

user-digest-help

2009-07-24


Author LoginPost Reply

user Digest 24 Jul 2009 20:59:18 -0000 Issue 8769

Topics (messages 201053 through 201082):

Re: studying struts2 framework, ActionInvocation question
 201053 by: Dimitrios Christodoulakis
 201062 by: Musachy Barroso
 201068 by: Dimitrios Christodoulakis
 201069 by: Dimitrios Christodoulakis
 201070 by: Musachy Barroso

Re: tag syntax question
 201054 by: Mitch Claborn
 201056 by: Dale Newfield
 201061 by: mailtolouis2020-struts.yahoo.com
 201067 by: Musachy Barroso

Re: custom tag development?
 201055 by: Mitch Claborn
 201064 by: Musachy Barroso

Downloading a Streamed File
 201057 by: Timothy Orme
 201059 by: Dale Newfield
 201072 by: Timothy Orme
 201075 by: Dale Newfield
 201076 by: Timothy Orme
 201078 by: Timothy Orme
 201079 by: Dale Newfield
 201080 by: Dale Newfield
 201082 by: Martin Gainty

Is this how convention plugin mapping works?
 201058 by: Jim Collings
 201065 by: Musachy Barroso
 201071 by: Jim Collings
 201073 by: Musachy Barroso
 201077 by: Jim Collings

Detailed map for convention plugin?
 201060 by: Jim Collings
 201066 by: Musachy Barroso

Issue with custom ExceptionMappingInterceptor
 201063 by: shanku

using 'method' in action mapping
 201074 by: Bhaarat Sharma

Re: s2 and default locale/language
 201081 by: kaphilmore

Administrivia:

---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)

----------------------------------------------------------------------


Attachment: user_201053.ezm (zipped)
I tried to logically trace the flow within the framework and wanted to
check if my thoughts are correct here, while at the same time asking a
few more questions:

As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
instantiates DefaultActionProxy, but also gives us
DefaultActionInvocation via its createActionProxy methods, using the
"new" operator.

The DefaultActionProxy constructor takes ActionInvocation as parameter
and sets the ActionInvocation interface field by means of a
DefaultActionInvocation implementation.

Next, DefaultActionInvocation takes extraContext and a boolean as
constructor params. It also has a reference to the ActionProxy which I
believe sets via its init method?

DefaultActionInvocation also creates the actions with its
createAction(Map<String, Object> contextMap) method, letting an
objectFactory take care of the actual creation with information taken
from the ActionProxy (like action name, name space, config, etc).

Then DefaultActionInvocation also invokes the action by calling
invokeAction(action, actionConfig).

This is more to help me understand the basic workflow at a higher
level at first. Are my above statements correct?

One thing that I find confusing (at this time) is the use of so many
"contexts": extraContext, actionContext, invocationContext, etc. What
is the primary use of the context? Is it similar to the configuration
object?

I still have as a short term objective to unit test my
intercept(actionInvocation) method of my custom Interceptor, but is it
true to assume that to prepare for the test I'd probably need to
create a lot of dependencies manually? i.e. Create mock objects all
the way deep to DefaultActionProxyFactory?

Many thanks again for your help.




On Thu, Jul 23, 2009 at 5:37 PM, Dave Newton<newton.dave@(protected):
> Dimitrios Christodoulakis wrote:
>>
>> By the way I noticed that when I downloaded the s2 source code, it
>> didn't come with the opensymphony packages... Does the xwork source
>> has to be downloaded separately?
>
> Yes.
>
> Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_201062.ezm (zipped)
You don't need to create mock objects for the framework, you onlt need
to mock the objects passed to the interceptor and invoke the
interceptor directly, unless you really want to test the interceptor
running inside struts (there is a long thread about that so i wont get
into it)

musachy

On Fri, Jul 24, 2009 at 6:31 AM, Dimitrios
Christodoulakis<dimi.chr@(protected):
> I tried to logically trace the flow within the framework and wanted to
> check if my thoughts are correct here, while at the same time asking a
> few more questions:
>
> As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
> instantiates DefaultActionProxy, but also gives us
> DefaultActionInvocation via its createActionProxy methods, using the
> "new" operator.
>
> The DefaultActionProxy constructor takes ActionInvocation as parameter
> and sets the ActionInvocation interface field by means of a
> DefaultActionInvocation implementation.
>
> Next, DefaultActionInvocation takes extraContext and a boolean as
> constructor params. It also has a reference to the ActionProxy which I
> believe sets via its init method?
>
> DefaultActionInvocation also creates the actions with its
> createAction(Map<String, Object> contextMap) method, letting an
> objectFactory take care of the actual creation with information taken
> from the ActionProxy (like action name, name space, config, etc).
>
> Then DefaultActionInvocation also invokes the action by calling
> invokeAction(action, actionConfig).
>
> This is more to help me understand the basic workflow at a higher
> level at first. Are my above statements correct?
>
> One thing that I find confusing (at this time) is the use of so many
> "contexts": extraContext, actionContext, invocationContext, etc. What
> is the primary use of the context? Is it similar to the configuration
> object?
>
> I still have as a short term objective to unit test my
> intercept(actionInvocation) method of my custom Interceptor, but is it
> true to assume that to prepare for the test I'd probably need to
> create a lot of dependencies manually? i.e. Create mock objects all
> the way deep to DefaultActionProxyFactory?
>
> Many thanks again for your help.
>
>
>
>
> On Thu, Jul 23, 2009 at 5:37 PM, Dave Newton<newton.dave@(protected):
>> Dimitrios Christodoulakis wrote:
>>>
>>> By the way I noticed that when I downloaded the s2 source code, it
>>> didn't come with the opensymphony packages... Does the xwork source
>>> has to be downloaded separately?
>>
>> Yes.
>>
>> Dave
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201068.ezm (zipped)
I plan to unit test the interceptor on its own. I am more interested
in testing its logic, not necessarily within the framework.

First step would be to mock an ActionInvocation object which is what
is passed to the Interceptor's intercept method. The action invocation
would need a mock action, and a mock session which will be holding the
user credentials. In order to have a session I would need to first
have an invocation object to get the session from:
actionInvocation.getInvocationContext().getSession()

On Fri, Jul 24, 2009 at 10:52 AM, Musachy Barroso<musachy@(protected):
> You don't need to create mock objects for the framework, you onlt need
> to mock the objects passed to the interceptor and invoke the
> interceptor directly, unless you really want to test the interceptor
> running inside struts (there is a long thread about that so i wont get
> into it)
>
> musachy
>
> On Fri, Jul 24, 2009 at 6:31 AM, Dimitrios
> Christodoulakis<dimi.chr@(protected):
>> I tried to logically trace the flow within the framework and wanted to
>> check if my thoughts are correct here, while at the same time asking a
>> few more questions:
>>
>> As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
>> instantiates DefaultActionProxy, but also gives us
>> DefaultActionInvocation via its createActionProxy methods, using the
>> "new" operator.
>>
>> The DefaultActionProxy constructor takes ActionInvocation as parameter
>> and sets the ActionInvocation interface field by means of a
>> DefaultActionInvocation implementation.
>>
>> Next, DefaultActionInvocation takes extraContext and a boolean as
>> constructor params. It also has a reference to the ActionProxy which I
>> believe sets via its init method?
>>
>> DefaultActionInvocation also creates the actions with its
>> createAction(Map<String, Object> contextMap) method, letting an
>> objectFactory take care of the actual creation with information taken
>> from the ActionProxy (like action name, name space, config, etc).
>>
>> Then DefaultActionInvocation also invokes the action by calling
>> invokeAction(action, actionConfig).
>>
>> This is more to help me understand the basic workflow at a higher
>> level at first. Are my above statements correct?
>>
>> One thing that I find confusing (at this time) is the use of so many
>> "contexts": extraContext, actionContext, invocationContext, etc. What
>> is the primary use of the context? Is it similar to the configuration
>> object?
>>
>> I still have as a short term objective to unit test my
>> intercept(actionInvocation) method of my custom Interceptor, but is it
>> true to assume that to prepare for the test I'd probably need to
>> create a lot of dependencies manually? i.e. Create mock objects all
>> the way deep to DefaultActionProxyFactory?
>>
>> Many thanks again for your help.
>>
>>
>>
>>
>> On Thu, Jul 23, 2009 at 5:37 PM, Dave Newton<newton.dave@(protected):
>>> Dimitrios Christodoulakis wrote:
>>>>
>>>> By the way I noticed that when I downloaded the s2 source code, it
>>>> didn't come with the opensymphony packages... Does the xwork source
>>>> has to be downloaded separately?
>>>
>>> Yes.
>>>
>>> Dave
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_201069.ezm (zipped)
Let me correct an error below, I meant: "... I would need to first
have an invocation *context* to get the session from..."

I still have difficulty grasping the idea of all the different
contexts, and their general use, but should be able to go ahead with
the unit test.

On Fri, Jul 24, 2009 at 11:14 AM, Dimitrios
Christodoulakis<dimi.chr@(protected):
> I plan to unit test the interceptor on its own. I am more interested
> in testing its logic, not necessarily within the framework.
>
> First step would be to mock an ActionInvocation object which is what
> is passed to the Interceptor's intercept method. The action invocation
> would need a mock action, and a mock session which will be holding the
> user credentials. In order to have a session I would need to first
> have an invocation object to get the session from:
> actionInvocation.getInvocationContext().getSession()
>
> On Fri, Jul 24, 2009 at 10:52 AM, Musachy Barroso<musachy@(protected):
>> You don't need to create mock objects for the framework, you onlt need
>> to mock the objects passed to the interceptor and invoke the
>> interceptor directly, unless you really want to test the interceptor
>> running inside struts (there is a long thread about that so i wont get
>> into it)
>>
>> musachy
>>
>> On Fri, Jul 24, 2009 at 6:31 AM, Dimitrios
>> Christodoulakis<dimi.chr@(protected):
>>> I tried to logically trace the flow within the framework and wanted to
>>> check if my thoughts are correct here, while at the same time asking a
>>> few more questions:
>>>
>>> As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
>>> instantiates DefaultActionProxy, but also gives us
>>> DefaultActionInvocation via its createActionProxy methods, using the
>>> "new" operator.
>>>
>>> The DefaultActionProxy constructor takes ActionInvocation as parameter
>>> and sets the ActionInvocation interface field by means of a
>>> DefaultActionInvocation implementation.
>>>
>>> Next, DefaultActionInvocation takes extraContext and a boolean as
>>> constructor params. It also has a reference to the ActionProxy which I
>>> believe sets via its init method?
>>>
>>> DefaultActionInvocation also creates the actions with its
>>> createAction(Map<String, Object> contextMap) method, letting an
>>> objectFactory take care of the actual creation with information taken
>>> from the ActionProxy (like action name, name space, config, etc).
>>>
>>> Then DefaultActionInvocation also invokes the action by calling
>>> invokeAction(action, actionConfig).
>>>
>>> This is more to help me understand the basic workflow at a higher
>>> level at first. Are my above statements correct?
>>>
>>> One thing that I find confusing (at this time) is the use of so many
>>> "contexts": extraContext, actionContext, invocationContext, etc. What
>>> is the primary use of the context? Is it similar to the configuration
>>> object?
>>>
>>> I still have as a short term objective to unit test my
>>> intercept(actionInvocation) method of my custom Interceptor, but is it
>>> true to assume that to prepare for the test I'd probably need to
>>> create a lot of dependencies manually? i.e. Create mock objects all
>>> the way deep to DefaultActionProxyFactory?
>>>
>>> Many thanks again for your help.
>>>
>>>
>>>
>>>
>>> On Thu, Jul 23, 2009 at 5:37 PM, Dave Newton<newton.dave@(protected):
>>>> Dimitrios Christodoulakis wrote:
>>>>>
>>>>> By the way I noticed that when I downloaded the s2 source code, it
>>>>> didn't come with the opensymphony packages... Does the xwork source
>>>>> has to be downloaded separately?
>>>>
>>>> Yes.
>>>>
>>>> Dave
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail: user-help@(protected)
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>


Attachment: user_201070.ezm (zipped)
using any of the 35,000 mocking frameworks available, that would be
pretty easy :)

musachy

On Fri, Jul 24, 2009 at 9:14 AM, Dimitrios
Christodoulakis<dimi.chr@(protected):
> I plan to unit test the interceptor on its own. I am more interested
> in testing its logic, not necessarily within the framework.
>
> First step would be to mock an ActionInvocation object which is what
> is passed to the Interceptor's intercept method. The action invocation
> would need a mock action, and a mock session which will be holding the
> user credentials. In order to have a session I would need to first
> have an invocation object to get the session from:
> actionInvocation.getInvocationContext().getSession()
>
> On Fri, Jul 24, 2009 at 10:52 AM, Musachy Barroso<musachy@(protected):
>> You don't need to create mock objects for the framework, you onlt need
>> to mock the objects passed to the interceptor and invoke the
>> interceptor directly, unless you really want to test the interceptor
>> running inside struts (there is a long thread about that so i wont get
>> into it)
>>
>> musachy
>>
>> On Fri, Jul 24, 2009 at 6:31 AM, Dimitrios
>> Christodoulakis<dimi.chr@(protected):
>>> I tried to logically trace the flow within the framework and wanted to
>>> check if my thoughts are correct here, while at the same time asking a
>>> few more questions:
>>>
>>> As a start I take DefaultActionProxyFactory. DefaultActionProxyFactory
>>> instantiates DefaultActionProxy, but also gives us
>>> DefaultActionInvocation via its createActionProxy methods, using the
>>> "new" operator.
>>>
>>> The DefaultActionProxy constructor takes ActionInvocation as parameter
>>> and sets the ActionInvocation interface field by means of a
>>> DefaultActionInvocation implementation.
>>>
>>> Next, DefaultActionInvocation takes extraContext and a boolean as
>>> constructor params. It also has a reference to the ActionProxy which I
>>> believe sets via its init method?
>>>
>>> DefaultActionInvocation also creates the actions with its
>>> createAction(Map<String, Object> contextMap) method, letting an
>>> objectFactory take care of the actual creation with information taken
>>> from the ActionProxy (like action name, name space, config, etc).
>>>
>>> Then DefaultActionInvocation also invokes the action by calling
>>> invokeAction(action, actionConfig).
>>>
>>> This is more to help me understand the basic workflow at a higher
>>> level at first. Are my above statements correct?
>>>
>>> One thing that I find confusing (at this time) is the use of so many
>>> "contexts": extraContext, actionContext, invocationContext, etc. What
>>> is the primary use of the context? Is it similar to the configuration
>>> object?
>>>
>>> I still have as a short term objective to unit test my
>>> intercept(actionInvocation) method of my custom Interceptor, but is it
>>> true to assume that to prepare for the test I'd probably need to
>>> create a lot of dependencies manually? i.e. Create mock objects all
>>> the way deep to DefaultActionProxyFactory?
>>>
>>> Many thanks again for your help.
>>>
>>>
>>>
>>>
>>> On Thu, Jul 23, 2009 at 5:37 PM, Dave Newton<newton.dave@(protected):
>>>> Dimitrios Christodoulakis wrote:
>>>>>
>>>>> By the way I noticed that when I downloaded the s2 source code, it
>>>>> didn't come with the opensymphony packages... Does the xwork source
>>>>> has to be downloaded separately?
>>>>
>>>> Yes.
>>>>
>>>> Dave
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail: user-help@(protected)
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201054.ezm (zipped)
Is either of the following more or less efficient than the other?

<s:property value="#request.something" />
<s:property value="%{#request.something}" />

mitch


Musachy Barroso wrote:
> other attributes are expected to be expressions, so you can do:
>
> <s:property value="#request.something" />
>
> instead of the more verbose, but also correct:
>
> <s:property value="%{#request.something}" />
>
>  
>


Attachment: user_201056.ezm (zipped)
Mitch Claborn wrote:
> Is either of the following more or less efficient than the other?
>
> <s:property value="#request.something" />
> <s:property value="%{#request.something}" />

I always argue that the latter should be used, just to avoid unnecessary
confusion later on.

-Dale


Attachment: user_201061.ezm (zipped)
Hi,

I've another tag syntax question

This not work:
<s:checkbox name="userId" value="selectedUserId" fieldValue="userId"/>

This work
<s:checkbox name="userId" value="selectedUserId" fieldValue="%{userId}"/>

This also work
<s:checkbox name="userId" value="%{selectedUserId}" fieldValue="%{userId}"/>

Why we need to use %{} for fieldValue but value doesn't require?

Regards
Louis




________________________________
From: Dale Newfield <dale@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Friday, July 24, 2009 3:31:36 PM
Subject: Re: tag syntax question

Mitch Claborn wrote:
> Is either of the following more or less efficient than the other?
>
> <s:property value="#request.something" />
> <s:property value="%{#request.something}" />

I always argue that the latter should be used, just to avoid unnecessary confusion later on.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment: user_201067.ezm (zipped)
I totally agree with Dale, using %{..} will save you a lot of headaches.

musachy

On Fri, Jul 24, 2009 at 7:31 AM, Dale Newfield<dale@(protected):
> Mitch Claborn wrote:
>>
>> Is either of the following more or less efficient than the other?
>>
>> <s:property value="#request.something" />
>> <s:property value="%{#request.something}" />
>
> I always argue that the latter should be used, just to avoid unnecessary
> confusion later on.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201055.ezm (zipped)
That's close to what I need, but not quite there.

custom5[<s:component template="t1.jsp" templateDir="myTemplates" >
this is stuff in the middle
</s:component>]


t1.jsp:
<%@(protected)" %>
this is t1.jsp.<br/>
done

renders as
custom5[
this is stuff in the middle

this is t1.jsp.<br/>
done
]


I need to be able to conditionally and repetitively render the content
within the tag. Any further ideas or pointers?


Mitch

Musachy Barroso wrote:
> Look at the "component" tag, you might be able to create a tag without
> writing any code.
>
> musachy
>
> On Thu, Jul 23, 2009 at 3:50 PM, Mitch Claborn<mitch@(protected):
>  
>> Hoping someone can give me some pointers on how to get started on
>> developing my own tag.
>>
>> I want to develop a custom tag to use within Struts 2, kind of like
>> <s:iterator>. What I have in mind is something like this:
>>
>> <abc:mytag>
>> other stuff, including other struts tags
>> </abc:mytag>
>>
>> the tag would iterate over the stuff contained in the tag, based on
>> non-trivial logic, and also generate output both before and after the
>> other stuff. This may eventually turn into a tag to generate an HTML
>> table. Any pointers on how to get started developing such an animal are
>> appreciated.
>>
>>
>> Mitch
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>  
>
>
>
>  


Attachment: user_201064.ezm (zipped)
you can still use the struts tags and/or jstl in the component.

musachy

On Fri, Jul 24, 2009 at 7:20 AM, Mitch Claborn<mitch@(protected):
> That's close to what I need, but not quite there.
>
> custom5[<s:component template="t1.jsp" templateDir="myTemplates" >
>  this is stuff in the middle
> </s:component>]
>
>
> t1.jsp:
> <%@(protected)" %>
> this is t1.jsp.<br/>
> done
>
> renders as
> custom5[
>  this is stuff in the middle
>
> this is t1.jsp.<br/>
> done
> ]
>
>
> I need to be able to conditionally and repetitively render the content
> within the tag.  Any further ideas or pointers?
>
>
> Mitch
>
> Musachy Barroso wrote:
>> Look at the "component" tag, you might be able to create a tag without
>> writing any code.
>>
>> musachy
>>
>> On Thu, Jul 23, 2009 at 3:50 PM, Mitch Claborn<mitch@(protected):
>>
>>> Hoping someone can give me some pointers on how to get started on
>>> developing my own tag.
>>>
>>> I want to develop a custom tag to use within Struts 2, kind of like
>>> <s:iterator>.  What I have in mind is something like this:
>>>
>>> <abc:mytag>
>>> other stuff, including other struts tags
>>> </abc:mytag>
>>>
>>> the tag would iterate over the stuff contained in the tag, based on
>>> non-trivial logic, and also generate output both before and after the
>>> other stuff.  This may eventually turn into a tag to generate an HTML
>>> table.  Any pointers on how to get started developing such an animal are
>>> appreciated.
>>>
>>>
>>> Mitch
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201057.ezm (zipped)
Hello,

 I did some digging on this but couldn't find anything. I have an action which is returning a streamed result. I create a zip file in memory and stream it out to the user. This works fine when the
user simply clicks the link. I get the correct file, with the right name. However, as of right now, if the user right clicks on the link and goes to "Save Link As", the link comes up to save as the
action name instead of the zip file, and it gives the following error:

Exception java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the &lt;param name=&quot;inputName&quot;&gt; tag specified
for this action.

However, if I click the link it works fine.

The code in my action looks like:

 public InputStream getInputStream() throws Exception{
   
   String contentType="application/octet-stream";
   
   Result result = ActionContext.getContext().getActionInvocation().getResult();
   if(result != null && result instanceof StreamResult){
     StreamResult streamResult = (StreamResult)result;
     streamResult.setContentType(contentType);
     streamResult.setContentDisposition("attachment; filename=\"" + plateName + ".zip\"");
   }
   
   return new ByteArrayInputStream(bos.toByteArray());
   
 }

Any suggestions? Ideally I'd like the user to be able to right click and save the link and get the correct zip file. I feel as though I've seen this done on other sites, but can't find an example.

Thanks,
Tim



Attachment: user_201059.ezm (zipped)
Why are you trying to modify the result once it's already running rather
than configuring it in your struts.xml?

http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html

Note, there's a bug in that documentation that'll be fixed in the next
release, which you've already figured: instead of
'filename="document.pdf"' it should be 'attachment;filename="document.pdf"'.

-Dale


Attachment: user_201072.ezm (zipped)
Hey,

 Not sure where I got this from, but I've corrected it so that all the properties are in the struts.xml instead of modifying it in the code. I still have the same issue though. Right clicking the link
doesn't work and the filename is still listed as the action.

Thanks,
Tim

Dale Newfield wrote:
> Why are you trying to modify the result once it's already running rather
> than configuring it in your struts.xml?
>
> http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html
>
>
> Note, there's a bug in that documentation that'll be fixed in the next
> release, which you've already figured: instead of
> 'filename="document.pdf"' it should be
> 'attachment;filename="document.pdf"'.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>



Attachment: user_201075.ezm (zipped)
Timothy Orme wrote:
> I still have the same issue though. Right clicking the link
> doesn't work and the filename is still listed as the action.

As far as struts is concerned, there's no difference between a request
that's going to be displayed in a browser window and a request that's
going to be saved by the browser to a file. I'd start by looking at
URLs and logs and seeing how those requests differ from one another.
For example, make sure your browser (or proxy or something) isn't
showing you a cached version of the left-click result.

If you want help, you need to provide enough of your configuration for
us to diagnose what's going on, assuming the request is being mapped to
that action.

-Dale


Attachment: user_201076.ezm (zipped)
Right, I figured that it wasn't a struts specific issue, but thought that I might have been using the wrong content disposition or something along those lines.

However, upon further prodding, it seems that this is more an issue of response time with the browser.

I found that the behavior I was seeking worked with the JasperReports plugin. The user clicked on a .action link and got a PDF. Right clicking to save as gave them the .pdf as well.

However, if I set a break point in my report generation code to halt it, the browser forces the "Save as" dialog to appear, but at this point it hasn't received any response yet, so it doesn't know
what the content disposition, and instead of the usual filename being set to a PDF, I get the same "bad" behavior of it saving as the action name. This kind of makes sense from the browsers
perspective though, since it'd be odd to click to save a link, only to have the browser apparently hang while the dialog waits for a response.

My problem really then, is that my action to make a zip simply takes too long to do its thing, and the browser refuses to wait.

I'm not sure if theres really a workaround for this, other than writing to disk and linking directly to the file.

I'm not sure what other parts of my config you need, but heres the struts.xml for that action:

<action name="DownloadFile" class="action.DownloadFileAction">
 <result name="success" type="stream">
   <param name="inputName">inputStream</param>
   <param name="contentType">application/octet-stream</param>
   <param name="contentDisposition">attachment; filename="${fileName}.zip"</param>
 </result>
 
 <result name="input" type="redirect">ViewDownloadForm.action</result>
</action>


Thanks,
Tim

Dale Newfield wrote:
> Timothy Orme wrote:
>> I still have the same issue though. Right clicking the link doesn't
>> work and the filename is still listed as the action.
>
> As far as struts is concerned, there's no difference between a request
> that's going to be displayed in a browser window and a request that's
> going to be saved by the browser to a file. I'd start by looking at
> URLs and logs and seeing how those requests differ from one another. For
> example, make sure your browser (or proxy or something) isn't showing
> you a cached version of the left-click result.
>
> If you want help, you need to provide enough of your configuration for
> us to diagnose what's going on, assuming the request is being mapped to
> that action.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>



Attachment: user_201078.ezm (zipped)
And some further digging for those who are interested:

https://bugzilla.mozilla.org/show_bug.cgi?id=299372#c89

Apparently just a "bug" in firefox, though they have no intentions of fixing it.

Another link with more info about it in the wild:

http://drupal.org/node/74983

Thanks,
Tim Orme

Timothy Orme wrote:
> Right, I figured that it wasn't a struts specific issue, but thought
> that I might have been using the wrong content disposition or something
> along those lines.
>
> However, upon further prodding, it seems that this is more an issue of
> response time with the browser.
>
> I found that the behavior I was seeking worked with the JasperReports
> plugin. The user clicked on a .action link and got a PDF. Right clicking
> to save as gave them the .pdf as well.
>
> However, if I set a break point in my report generation code to halt it,
> the browser forces the "Save as" dialog to appear, but at this point it
> hasn't received any response yet, so it doesn't know what the content
> disposition, and instead of the usual filename being set to a PDF, I get
> the same "bad" behavior of it saving as the action name. This kind of
> makes sense from the browsers perspective though, since it'd be odd to
> click to save a link, only to have the browser apparently hang while the
> dialog waits for a response.
>
> My problem really then, is that my action to make a zip simply takes too
> long to do its thing, and the browser refuses to wait.
>
> I'm not sure if theres really a workaround for this, other than writing
> to disk and linking directly to the file.
>
> I'm not sure what other parts of my config you need, but heres the
> struts.xml for that action:
>
> <action name="DownloadFile" class="action.DownloadFileAction">
>   <result name="success" type="stream">
>      <param name="inputName">inputStream</param>
>      <param name="contentType">application/octet-stream</param>
>      <param name="contentDisposition">attachment;
> filename="${fileName}.zip"</param>
>   </result>
>  
>   <result name="input" type="redirect">ViewDownloadForm.action</result>
> </action>
>
>
> Thanks,
> Tim
>
> Dale Newfield wrote:
>> Timothy Orme wrote:
>>> I still have the same issue though. Right clicking the link doesn't
>>> work and the filename is still listed as the action.
>>
>> As far as struts is concerned, there's no difference between a request
>> that's going to be displayed in a browser window and a request that's
>> going to be saved by the browser to a file. I'd start by looking at
>> URLs and logs and seeing how those requests differ from one another.
>> For example, make sure your browser (or proxy or something) isn't
>> showing you a cached version of the left-click result.
>>
>> If you want help, you need to provide enough of your configuration for
>> us to diagnose what's going on, assuming the request is being mapped
>> to that action.
>>
>> -Dale
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>



Attachment: user_201079.ezm (zipped)
Timothy Orme wrote:
> My problem really then, is that my action to make a zip simply takes too
> long to do its thing, and the browser refuses to wait.

I don't know if this'll help you, but you could create and use a
modified version of StreamResult that makes many more of the
response.addHeader() and response.setXxx() calls before the InputStream
is requested from your action (which I believe is where you're saying
your action takes too long). This *might* enable more of the header to
be sent out to the browser earlier...

>      <param name="contentDisposition">attachment;
> filename="${fileName}.zip"</param>

It appears that you've got a space after that semicolon, which from my
reading of the HTTP specification shouldn't be there. Presumably most
browsers don't care, but...

Oh, and now in your struts.xml you can now use ognl's "%{}" instead of
jstl's "${}".

-Dale


Attachment: user_201080.ezm (zipped)
Timothy Orme wrote:
> I'm not sure if theres really a workaround for this, other than writing
> to disk and linking directly to the file.

Or monkeying with the url (and maybe the extensions that map to struts)
so that you can make the url of the action end with .../filename.zip .

-Dale


Attachment: user_201082.ezm (zipped)

good call dale

although the regular HTTP 1.1 (coyote) connection easily pushes capacity envelope with streaming
at last count was 8192 ..stop...go up to site ..get next chunk

there are *newer Asynch connectors* coming down the pike that will expand capacity for large chunked/unchunked blobs xfers...as a test site i would try the offering here (Author recites preface as a streaming video)
http://www.hup.harvard.edu/catalog/DANAFR.html

good to hear the crimson point of view

Martin Gainty
______________________________________________
Note de déni et de confidentialité

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: Fri, 24 Jul 2009 13:53:36 -0400
> From: dale@(protected)
> To: user@(protected)
> Subject: Re: Downloading a Streamed File
>
> Timothy Orme wrote:
> > I still have the same issue though. Right clicking the link
> > doesn't work and the filename is still listed as the action.
>
> As far as struts is concerned, there's no difference between a request
> that's going to be displayed in a browser window and a request that's
> going to be saved by the browser to a file. I'd start by looking at
> URLs and logs and seeing how those requests differ from one another.
> For example, make sure your browser (or proxy or something) isn't
> showing you a cached version of the left-click result.
>
> If you want help, you need to provide enough of your configuration for
> us to diagnose what's going on, assuming the request is being mapped to
> that action.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>

_________________________________________________________________
NEW mobile Hotmail. Optimized for YOUR phone. Click here.
http://windowslive.com/Mobile?ocid=TXT_TAGLM_WL_CS_MB_new_hotmail_072009

Attachment: user_201058.ezm (zipped)
User loads up a URL that calls an action named SomethingAction which
is an mostly empty action. It just sends em to the something.jsp page
by returning "success". What if there is a something-success page?
Will the behavior change?

On the something.jsp page, the user submits a form that calls another
action. This one is called SomethingElseAction. It's not in a
different package so the url is simply "http://server/something-else".
SomethingElseAction returns "input" which routes the user to a page
called something-else-input.

This sound right?


Attachment: user_201065.ezm (zipped)
yes that's how it works. for any action "MyAction", the "success"
result can be "my-action-success.jsp" or "my-action.jsp". For any
other result "x", the result is "my-action-x.jsp". (jsp is just an
example, it could be ftl or vm, etc)

musachy

On Fri, Jul 24, 2009 at 7:48 AM, Jim Collings<jlistnews@(protected):
> User loads up a URL that calls an action named SomethingAction which
> is an mostly empty action. It just sends em to the something.jsp page
> by returning "success".  What if there is a something-success page?
> Will the behavior change?
>
> On the something.jsp page, the user submits a form that calls another
> action. This one is called SomethingElseAction. It's not in a
> different package so the url is simply "http://server/something-else".
>  SomethingElseAction returns "input" which routes the user to a page
> called something-else-input.
>
> This sound right?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201071.ezm (zipped)
OK, so what you are saying then, is that if the my-action-success.jsp
file exists, it will be the one selected and if it does not, then the
myaction.jsp will be the one selected. So that if they both exist,
then expect my-action-success.jsp to be the result.


Jim C.

On Fri, Jul 24, 2009 at 12:08 PM, Musachy Barroso<musachy@(protected):
> yes that's how it works. for any action "MyAction", the "success"
> result can be "my-action-success.jsp" or "my-action.jsp". For any
> other result "x", the result is "my-action-x.jsp". (jsp is just an
> example, it could be ftl or vm, etc)
>
> musachy
>
> On Fri, Jul 24, 2009 at 7:48 AM, Jim Collings<jlistnews@(protected):
>> User loads up a URL that calls an action named SomethingAction which
>> is an mostly empty action. It just sends em to the something.jsp page
>> by returning "success".  What if there is a something-success page?
>> Will the behavior change?
>>
>> On the something.jsp page, the user submits a form that calls another
>> action. This one is called SomethingElseAction. It's not in a
>> different package so the url is simply "http://server/something-else".
>>  SomethingElseAction returns "input" which routes the user to a page
>> called something-else-input.
>>
>> This sound right?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_201073.ezm (zipped)
yes, off the top of my head, which is *very* unreliable(specially on
Fridays when I can only think of happy hour) :)

musachy

On Fri, Jul 24, 2009 at 9:47 AM, Jim Collings<jlistnews@(protected):
> OK, so what you are saying then, is that if the my-action-success.jsp
> file exists, it will be the one selected and if it does not, then the
> myaction.jsp will be the one selected. So that if they both exist,
> then expect my-action-success.jsp to be the result.
>
>
> Jim C.
>
> On Fri, Jul 24, 2009 at 12:08 PM, Musachy Barroso<musachy@(protected):
>> yes that's how it works. for any action "MyAction", the "success"
>> result can be "my-action-success.jsp" or "my-action.jsp". For any
>> other result "x", the result is "my-action-x.jsp". (jsp is just an
>> example, it could be ftl or vm, etc)
>>
>> musachy
>>
>> On Fri, Jul 24, 2009 at 7:48 AM, Jim Collings<jlistnews@(protected):
>>> User loads up a URL that calls an action named SomethingAction which
>>> is an mostly empty action. It just sends em to the something.jsp page
>>> by returning "success".  What if there is a something-success page?
>>> Will the behavior change?
>>>
>>> On the something.jsp page, the user submits a form that calls another
>>> action. This one is called SomethingElseAction. It's not in a
>>> different package so the url is simply "http://server/something-else".
>>>  SomethingElseAction returns "input" which routes the user to a page
>>> called something-else-input.
>>>
>>> This sound right?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201077.ezm (zipped)
Musachy Barroso wrote:
> yes, off the top of my head, which is *very* unreliable(specially on
> Fridays when I can only think of happy hour) :)

Indeed. ;-)


Jim C.


Attachment: signature.asc (zipped)
Attachment: user_201060.ezm (zipped)
Is there a graphical map of the decision tree for mapping? I would
like to see something like that.

For example, it says in the documentation that OneTwoThreeAction maps
to one-two-three.jsp but I can't find where it delineates what will
happen if there is a one-two-three-success.jsp page. I remember I did
a lot of fish-flopping when I was trying to figure this out and I
don't remember what the answer is even now.

Jim C.


Attachment: user_201066.ezm (zipped)
I think that is pretty well explained in the docs, there is a table
that will show the behavior, also see my response to your previous
email.

musachy

On Fri, Jul 24, 2009 at 8:19 AM, Jim Collings<jlistnews@(protected):
> Is there a graphical map of the decision tree for mapping?  I would
> like to see something like that.
>
> For example, it says in the documentation that OneTwoThreeAction maps
> to one-two-three.jsp but I can't find where it delineates what will
> happen if there is a one-two-three-success.jsp page. I remember I did
> a lot of fish-flopping when I was trying to figure this out and I
> don't remember what the answer is even now.
>
> Jim C.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



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


Attachment: user_201063.ezm (zipped)

I have implemented a custom ExceptionMappingInterceptor. The custom
interceptor basically handles all the business exceptions thrown by the
service method. The one that implemented is getting executed fine whenever a
exception is throw however on broswer i cant see the same page and error
msg, where as i see the stack trace of exception...
I can see all the sysout messages on my console.
Please help me.

public class MyExceptionInterceptor extends ExceptionMappingInterceptor {

    protected void publishException(ActionInvocation actionInvocation,
               ExceptionHolder exceptionHolder) {
          System.out.println("********************start
publishException**********************");      
          super.publishException(actionInvocation, exceptionHolder);
          // ActionContext invocationContext = actionInvocation
          // .getInvocationContext();

          if (exceptionHolder.getException() instanceof
MyBusinessException) {
               MyBusinessException mecoBusinessException =
(MyBusinessException) exceptionHolder.getException();
               Object action = actionInvocation.getAction();
          System.out.println("*********** instanceof
MyBusinessException ******* ");        
               if (action instanceof ValidationAware) {
           System.out.println("****** instanceof ValidationAware
******** ");                        
                    ValidationAware va = (ValidationAware)
action;
                    String key =
myBusinessException.getErrorCode().getCode();
                    String message = "";
            System.out.println("********KEY: "+key);
                    if (actionInvocation.getAction() instanceof
ActionSupport) {
                    System.out.println("******** instanceof
ActionSupport ******* ");    
                          message = ((ActionSupport)
actionInvocation.getAction())
                                    .getText(key);
               System.out.println("******* instanceof ActionSupport
message*** "+message);                              
                    } else {
                          message = key;
                    }
                    // va.addActionError(message);
                    va.addActionError("INTERCEPTOR CALLED TO
PRINT ERROR CODE>>>>>>>>");
               }
          }
System.out.println("************************** end publishException
***********************");
    }
}



my struts config:

</interceptors>
<interceptor name="myExceptionInterceptor"
                   
class="com.xxx.yyy.web.interceptor.MyExceptionInterceptor">
               </interceptor>
               <interceptor-stack name="myExceptionStack">
                    <interceptor-ref name="defaultStack" />
                    <interceptor-ref
name="myExceptionInterceptor" />
</interceptor-stack>
          </interceptors>

<default-interceptor-ref name="myExceptionStack" />



-----------------------
Thanks in advance

--
Sent from the Struts - User mailing list archive at Nabble.com.



Attachment: user_201074.ezm (zipped)
If I have a mapping like the following
    <action name="selectionPage" class="ReportSelection"
method="passBy">
       <result>/reports/moneyowed/selectionpage.jsp</result>
    </action>

the passBy method is doing nothing but returning SUCCESS

When the above action mapping is ran and the jsp page consists something
like <s:property value"%{value}"/> will the value show??

will providing attribute method in the actionmapping cause it to not have
access to public methods in the actionclass?

Attachment: user_201081.ezm (zipped)
Is it possible you have the locale configured in your struts.xml like this --

<constant name="struts.locale" value="de_De" />

If so, you're properties files will not change based on locale.


--- In struts@(protected):
>
>
>
> Hi!
>
> meanwhile I've found something interresting: My application is running on
> Apache Tomcat. When I set the
> "-Duser.language=en -Duser.region=US" for Tomcat, Struts doesn't use de as
> default language anymore.
>
>
> Titus
>
>
>
> Pascal-53 wrote:
> >
> > Hm, ok. Could you post your resource bundle initialization/usage?
> >
> > Pascal
> >
> > On Thu, 23 Jul 2009 04:18:50 -0700 (PDT), Marsman <mars.man@(protected):
> >> I've tried the browser language detection page and as I expected only the
> >> language code "da-DK" was listed. I had already removed the languages
> > de-DE
> >> and en-US an the browser and addad da-Dk to test my Struts configuration.
> >>
> >> Titus
> >>
> >>
> >>
> >> Pascal-53 wrote:
> >>>
> >>> Are you sure your browser settings are correct? I bet it's on the client
> >>> side, not a struts/config error.
> >>>
> >>> Try using some page to detect your language setting, like
> >>> http://aruljohn.com/lang.php
> >>>
> >>> Hope this helps,
> >>>
> >>> Pascal
> >>>
> >>> On Thu, 23 Jul 2009 03:24:50 -0700 (PDT), Marsman <mars.man@...>
> >>> wrote:
> >>>> Hi!
> >>>
> >>>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@...
> > For additional commands, e-mail: user-help@...
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/s2-and-default-locale-language-tp24623075p24642168.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>



©2008 gg3721.com - Jax Systems, LLC, U.S.A.