Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 30 Jul 2008 23:04:48 -0000 Issue 8170

user-digest-help

2008-07-30


Author LoginPost Reply

user Digest 30 Jul 2008 23:04:48 -0000 Issue 8170

Topics (messages 189480 through 189505):

Re: ServletOutputStream
 189480 by: Mike Rooney
 189489 by: Miguel
 189491 by: Gabriel Belingueres
 189502 by: Mike Rooney

Re: [S2] Testing if session variable is present
 189481 by: Marcos Hermida
 189482 by: Milan Milanovic
 189483 by: Milan Milanovic
 189484 by: Milan Milanovic

Re: [S2] Form doesn't redirect
 189485 by: Nick Scavelli
 189488 by: Dave Newton

Wierd Validation
 189486 by: Gundersen, Richard
 189503 by: Laurie Harper

Disable validation when clicking back
 189487 by: Dimitris Mouchritsas

Re: possibly strange namespace use case
 189490 by: Andy Law
 189505 by: Jeromy Evans

[S2] <s:action> not re-executed on INPUT result
 189492 by: Pierre Thibaudeau

Struts 2 And JFreeChart
 189493 by: cree
 189494 by: cree

[S2] error style on s:textfield
 189495 by: Pierre Thibaudeau
 189496 by: Dasgupta, Ranjan
 189497 by: Pierre Thibaudeau

Re: Strtus2 tags IE issue error loading page 200 ok
 189498 by: dynamicd

Re: struts record output and entry
 189499 by: Laurie Harper

Re: Redirect after stream result
 189500 by: Laurie Harper

Re: Is it a bug in Struts 1.2 that you can't iterate through a java.util.Set?
 189501 by: Laurie Harper

Strange Behaviour in FireFox3
 189504 by: nauke.

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_189480.ezm (zipped)
Thank you for the reply.  I know my action can only return one response.  However I want to avoid saving my file somewhere on the server and would like the 'File Download' dialog to appear when the file is ready.  How can I do this in struts 2 while still forwarding to a 'status completed' page? Would it be possible to store the file data in a session and somehow have the File Download dialog show up?  If so I am not sure how to do that.



----- Original Message ----
From: Gabriel Belingueres <belingueres@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Wednesday, July 30, 2008 3:59:29 AM
Subject: Re: ServletOutputStream

Your action can not generate two responses (if that's what you asking).
If you forward to a 'status completed' page, then you need to save
your excel data somewhere to not loosing it.

2008/7/29 Mike Rooney <okokabcde@(protected)>:
> I created a small webapp that extracts data from a DB, creates an Excel file from that data (using Apache POI), which then streams the file to the end user's browser.  Everything is working fine, however I have to set the Action class' return type to 'NULL' since I am setting the servlet response type to 'application/vnd-ms-excel'.  I want to change my application so that it returns to a 'status completed' page when the extraction is completed. However I cannot do this when I set the return type is null.  How can I do this?
>
> Here is my code...
>
> public class ExtractAction extends ActionSupport {
>  public String execute() throws Exception {
>    HSSFWorkbook wb = new HSSFWorkbook();
>    HSSFSheet prodSheet = wb.createSheet("PROD");
>    HSSFSheet devSheet = wb.createSheet("DEV");
>    HSSFSheet testSheet = wb.createSheet("TEST");
>    ...
>    HttpServletResponse response = ServletActionContext.getResponse();
>    response.setContentType("application/vnd.ms-excel");
>    ServletOutputStream outstream = response.getOutputStream();
>    wb.write(outstream);
>    outstream.flush();
>    response.flushBuffer();
>  }
>  return null;
>  //return SUCCESS
> }
>
> and my struts.xml
>
> <struts>
>
>  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>  <constant name="struts.devMode" value="false" />
>
>  <package name="default" extends="struts-default">
>    <action name="Extractor" class="action.ExtractAction">
>      <result name="success">/example/index.jsp</result>
>    </action>
>  </package>
>
> </struts>
>
>
>

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



Attachment: user_189489.ezm (zipped)
To send only one response it's a inherent limitation or http, so you
can only send a page, or the excel result or redirect, but not many at
once.
What you can do is put a "downloading page" and from that page use a
script to begin the downloading of the excel data from a different
action.
If you want to show the save data dialog, use the content disponsition header.

Si quieres ser más positivo, pierde un electrón
Miguel Ruiz Velasco S.



On Wed, Jul 30, 2008 at 10:19, Mike Rooney <okokabcde@(protected):
> Thank you for the reply. I know my action can only return one response. However I want to avoid saving my file somewhere on the server and would like the 'File Download' dialog to appear when the file is ready. How can I do this in struts 2 while still forwarding to a 'status completed' page? Would it be possible to store the file data in a session and somehow have the File Download dialog show up? If so I am not sure how to do that.
>
>
>
> ----- Original Message ----
> From: Gabriel Belingueres <belingueres@(protected)>
> To: Struts Users Mailing List <user@(protected)>
> Sent: Wednesday, July 30, 2008 3:59:29 AM
> Subject: Re: ServletOutputStream
>
> Your action can not generate two responses (if that's what you asking).
> If you forward to a 'status completed' page, then you need to save
> your excel data somewhere to not loosing it.
>
> 2008/7/29 Mike Rooney <okokabcde@(protected)>:
>> I created a small webapp that extracts data from a DB, creates an Excel file from that data (using Apache POI), which then streams the file to the end user's browser. Everything is working fine, however I have to set the Action class' return type to 'NULL' since I am setting the servlet response type to 'application/vnd-ms-excel'. I want to change my application so that it returns to a 'status completed' page when the extraction is completed. However I cannot do this when I set the return type is null. How can I do this?
>>
>> Here is my code...
>>
>> public class ExtractAction extends ActionSupport {
>> public String execute() throws Exception {
>>   HSSFWorkbook wb = new HSSFWorkbook();
>>   HSSFSheet prodSheet = wb.createSheet("PROD");
>>   HSSFSheet devSheet = wb.createSheet("DEV");
>>   HSSFSheet testSheet = wb.createSheet("TEST");
>>   ...
>>   HttpServletResponse response = ServletActionContext.getResponse();
>>   response.setContentType("application/vnd.ms-excel");
>>   ServletOutputStream outstream = response.getOutputStream();
>>   wb.write(outstream);
>>   outstream.flush();
>>   response.flushBuffer();
>> }
>> return null;
>> //return SUCCESS
>> }
>>
>> and my struts.xml
>>
>> <struts>
>>
>> <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>> <constant name="struts.devMode" value="false" />
>>
>> <package name="default" extends="struts-default">
>>   <action name="Extractor" class="action.ExtractAction">
>>    <result name="success">/example/index.jsp</result>
>>   </action>
>> </package>
>>
>> </struts>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

Attachment: user_189491.ezm (zipped)
A solution could be this: Store the excel data in session, then in
your 'status completed' page add an onload event to its body,
redirecting to the real download action:

IIRC:

<body onload="document.location.href='http://blahblah/myaction.action';">

You can also add a meta in the head:

<head>
  <META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://blahblah/myaction.action">
</head>

2008/7/30 Mike Rooney <okokabcde@(protected)>:
> Thank you for the reply. I know my action can only return one response. However I want to avoid saving my file somewhere on the server and would like the 'File Download' dialog to appear when the file is ready. How can I do this in struts 2 while still forwarding to a 'status completed' page? Would it be possible to store the file data in a session and somehow have the File Download dialog show up? If so I am not sure how to do that.
>
>
>
> ----- Original Message ----
> From: Gabriel Belingueres <belingueres@(protected)>
> To: Struts Users Mailing List <user@(protected)>
> Sent: Wednesday, July 30, 2008 3:59:29 AM
> Subject: Re: ServletOutputStream
>
> Your action can not generate two responses (if that's what you asking).
> If you forward to a 'status completed' page, then you need to save
> your excel data somewhere to not loosing it.
>
> 2008/7/29 Mike Rooney <okokabcde@(protected)>:
>> I created a small webapp that extracts data from a DB, creates an Excel file from that data (using Apache POI), which then streams the file to the end user's browser. Everything is working fine, however I have to set the Action class' return type to 'NULL' since I am setting the servlet response type to 'application/vnd-ms-excel'. I want to change my application so that it returns to a 'status completed' page when the extraction is completed. However I cannot do this when I set the return type is null. How can I do this?
>>
>> Here is my code...
>>
>> public class ExtractAction extends ActionSupport {
>> public String execute() throws Exception {
>>   HSSFWorkbook wb = new HSSFWorkbook();
>>   HSSFSheet prodSheet = wb.createSheet("PROD");
>>   HSSFSheet devSheet = wb.createSheet("DEV");
>>   HSSFSheet testSheet = wb.createSheet("TEST");
>>   ...
>>   HttpServletResponse response = ServletActionContext.getResponse();
>>   response.setContentType("application/vnd.ms-excel");
>>   ServletOutputStream outstream = response.getOutputStream();
>>   wb.write(outstream);
>>   outstream.flush();
>>   response.flushBuffer();
>> }
>> return null;
>> //return SUCCESS
>> }
>>
>> and my struts.xml
>>
>> <struts>
>>
>> <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>> <constant name="struts.devMode" value="false" />
>>
>> <package name="default" extends="struts-default">
>>   <action name="Extractor" class="action.ExtractAction">
>>    <result name="success">/example/index.jsp</result>
>>   </action>
>> </package>
>>
>> </struts>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

Attachment: user_189502.ezm (zipped)
Thank you for the help guys. I got it working.



----- Original Message ----
From: Gabriel Belingueres <belingueres@(protected)>
To: Struts Users Mailing List <user@(protected)>
Sent: Wednesday, July 30, 2008 10:58:43 AM
Subject: Re: ServletOutputStream

A solution could be this: Store the excel data in session, then in
your 'status completed' page add an onload event to its body,
redirecting to the real download action:

IIRC:

<body onload="document.location.href='http://blahblah/myaction.action';">

You can also add a meta in the head:

<head>
    <META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://blahblah/myaction.action">
</head>

2008/7/30 Mike Rooney <okokabcde@(protected)>:
> Thank you for the reply.  I know my action can only return one response.  However I want to avoid saving my file somewhere on the server and would like the 'File Download' dialog to appear when the file is ready.  How can I do this in struts 2 while still forwarding to a 'status completed' page? Would it be possible to store the file data in a session and somehow have the File Download dialog show up?  If so I am not sure how to do that.
>
>
>
> ----- Original Message ----
> From: Gabriel Belingueres <belingueres@(protected)>
> To: Struts Users Mailing List <user@(protected)>
> Sent: Wednesday, July 30, 2008 3:59:29 AM
> Subject: Re: ServletOutputStream
>
> Your action can not generate two responses (if that's what you asking).
> If you forward to a 'status completed' page, then you need to save
> your excel data somewhere to not loosing it.
>
> 2008/7/29 Mike Rooney <okokabcde@(protected)>:
>> I created a small webapp that extracts data from a DB, creates an Excel file from that data (using Apache POI), which then streams the file to the end user's browser.  Everything is working fine, however I have to set the Action class' return type to 'NULL' since I am setting the servlet response type to 'application/vnd-ms-excel'.  I want to change my application so that it returns to a 'status completed' page when the extraction is completed. However I cannot do this when I set the return type is null.  How can I do this?
>>
>> Here is my code...
>>
>> public class ExtractAction extends ActionSupport {
>>  public String execute() throws Exception {
>>    HSSFWorkbook wb = new HSSFWorkbook();
>>    HSSFSheet prodSheet = wb.createSheet("PROD");
>>    HSSFSheet devSheet = wb.createSheet("DEV");
>>    HSSFSheet testSheet = wb.createSheet("TEST");
>>    ...
>>    HttpServletResponse response = ServletActionContext.getResponse();
>>    response.setContentType("application/vnd.ms-excel");
>>    ServletOutputStream outstream = response.getOutputStream();
>>    wb.write(outstream);
>>    outstream.flush();
>>    response.flushBuffer();
>>  }
>>  return null;
>>  //return SUCCESS
>> }
>>
>> and my struts.xml
>>
>> <struts>
>>
>>  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>>  <constant name="struts.devMode" value="false" />
>>
>>  <package name="default" extends="struts-default">
>>    <action name="Extractor" class="action.ExtractAction">
>>      <result name="success">/example/index.jsp</result>
>>    </action>
>>  </package>
>>
>> </struts>
>>
>>
>>
>
> ---------------------------------------------------------------------
> 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_189481.ezm (zipped)
Have you tried this:
<s:if test="#session['your_variable']!= null">


Milan Milanovic escribió:
> Well, this : <s:if test="%{#session.your_variable != null}"> doesn't work,
> event though my class implements sessionAware and I put my your_variable in
> session before displaying this jsp page.
>
> What can I do ?
>
> --
> Thx, Milan
>
>
>
> felipe.lorenz wrote:
>  
>> Hummm.. Struts 1 or 2?
>>
>> This code is to S2.
>>
>> <s:if test="%{#session.your_variable != null}">
>>
>>   do something
>>
>> </s:if>
>>
>> I didnt test it, so im not sure about the code.
>>
>> But try it, and tell us.
>>
>> Felipe Lorenz
>>
>> On Tue, Jul 29, 2008 at 9:34 AM, Milan Milanovic
>> <milanmilanovich@(protected):
>>
>>  
>>> Hi,
>>>
>>> I need to test in jsp if some session variable is present, and based on
>>> that
>>> to
>>> show some struts view code or not. How can I do that ?
>>>
>>> --
>>> Thx, Milan
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-S2--Testing-if-session-variable-is-present-tp18716278p18716278.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>>    
>>  
>
>  


Attachment: user_189482.ezm (zipped)

Hi,

just to note, I treid with this too: <s:if test="#session.your_variable !=
null"> and it doesn't work.
I put my session variable in one action class, and then redirect to another
page which is connected to another action class. When that second class
method is runned, and resulting jsp is shown in that page I test this. My
both classes implements sessionAware.

--
Milan



Milan Milanovic wrote:
>
> Well, this : <s:if test="%{#session.your_variable != null}"> doesn't work,
> event though my class implements sessionAware and I put my your_variable
> in session before displaying this jsp page.
>
> I should note that I put that variable in one action class and then that
> <s:if> test is runned in jsp for another action class, but both classes
> implements sessionAware.
>
> What can I do ?
>
> --
> Thx, Milan
>
>
>
> felipe.lorenz wrote:
>>
>> Hummm.. Struts 1 or 2?
>>
>> This code is to S2.
>>
>> <s:if test="%{#session.your_variable != null}">
>>
>>   do something
>>
>> </s:if>
>>
>> I didnt test it, so im not sure about the code.
>>
>> But try it, and tell us.
>>
>> Felipe Lorenz
>>
>> On Tue, Jul 29, 2008 at 9:34 AM, Milan Milanovic
>> <milanmilanovich@(protected):
>>
>>>
>>> Hi,
>>>
>>> I need to test in jsp if some session variable is present, and based on
>>> that
>>> to
>>> show some struts view code or not. How can I do that ?
>>>
>>> --
>>> Thx, Milan
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-S2--Testing-if-session-variable-is-present-tp18716278p18716278.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>>
>
>

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


Attachment: user_189483.ezm (zipped)

Nop, it doesn't work.

--
Milan


Marcos Hermida-2 wrote:
>
> Have you tried this:
> <s:if test="#session['your_variable']!= null">
>
>
> Milan Milanovic escribió:
>> Well, this : <s:if test="%{#session.your_variable != null}"> doesn't
>> work,
>> event though my class implements sessionAware and I put my your_variable
>> in
>> session before displaying this jsp page.
>>
>> What can I do ?
>>
>> --
>> Thx, Milan
>>
>>
>>
>> felipe.lorenz wrote:
>>  
>>> Hummm.. Struts 1 or 2?
>>>
>>> This code is to S2.
>>>
>>> <s:if test="%{#session.your_variable != null}">
>>>
>>>   do something
>>>
>>> </s:if>
>>>
>>> I didnt test it, so im not sure about the code.
>>>
>>> But try it, and tell us.
>>>
>>> Felipe Lorenz
>>>
>>> On Tue, Jul 29, 2008 at 9:34 AM, Milan Milanovic
>>> <milanmilanovich@(protected):
>>>
>>>  
>>>> Hi,
>>>>
>>>> I need to test in jsp if some session variable is present, and based on
>>>> that
>>>> to
>>>> show some struts view code or not. How can I do that ?
>>>>
>>>> --
>>>> Thx, Milan
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/-S2--Testing-if-session-variable-is-present-tp18716278p18716278.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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)
>
>
>

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


Attachment: user_189484.ezm (zipped)

So, scenario is like this:

MyFirstAction.method1 [put session variable] -> show first.jsp -> user click
on link in first.jsp page -> show second.jsp -> user click on link in
second.jsp -> MySecondAction.someMethod is called -> show third.jsp where
this session test should be done.

I hope this helps.

--
Thx, Milan


Milan Milanovic wrote:
>
> Hi,
>
> just to note, I treid with this too: <s:if test="#session.your_variable !=
> null"> and it doesn't work.
> I put my session variable in one action class, and then redirect to
> another page which is connected to another action class. When that second
> class method is runned, and resulting jsp is shown in that page I test
> this. My both classes implements sessionAware.
>
> --
> Milan
>
>
>
> Milan Milanovic wrote:
>>
>> Well, this : <s:if test="%{#session.your_variable != null}"> doesn't
>> work, event though my class implements sessionAware and I put my
>> your_variable in session before displaying this jsp page.
>>
>> I should note that I put that variable in one action class and then that
>> <s:if> test is runned in jsp for another action class, but both classes
>> implements sessionAware.
>>
>> What can I do ?
>>
>> --
>> Thx, Milan
>>
>>
>>
>> felipe.lorenz wrote:
>>>
>>> Hummm.. Struts 1 or 2?
>>>
>>> This code is to S2.
>>>
>>> <s:if test="%{#session.your_variable != null}">
>>>
>>>   do something
>>>
>>> </s:if>
>>>
>>> I didnt test it, so im not sure about the code.
>>>
>>> But try it, and tell us.
>>>
>>> Felipe Lorenz
>>>
>>> On Tue, Jul 29, 2008 at 9:34 AM, Milan Milanovic
>>> <milanmilanovich@(protected):
>>>
>>>>
>>>> Hi,
>>>>
>>>> I need to test in jsp if some session variable is present, and based on
>>>> that
>>>> to
>>>> show some struts view code or not. How can I do that ?
>>>>
>>>> --
>>>> Thx, Milan
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/-S2--Testing-if-session-variable-is-present-tp18716278p18716278.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail: user-help@(protected)
>>>>
>>>>
>>>
>>>
>>
>>
>
>

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


Attachment: user_189485.ezm (zipped)
I'm replying to this because it's somewhat related to an issue I'm having.

Let's say I have the following control in my jsp:
<sx:submit type="button" method="search" value="Search"
targets="resultsDiv" indicator="indicator"/>

This of course will update the div defined in my jsp:
<div id="resultsDiv"/>

Everything works great under normal circumstances. But let's say my
session has timed out, and I need to redirect to the login page. In
my circumstance the div is replaced by the login jsp, which just looks
strange. What are the best practices with dealing with these
situations using Ajax.

- Nick

On Mon, Jul 28, 2008 at 8:28 AM, Dave Newton <newton.dave@(protected):
> --- On Mon, 7/28/08, Milan Milanovic <milanmilanovich@(protected):
>> well I don't understand what is the problem, I use ajax
>> for my first form, but not to second which should redirect?
>
> ...
>
> Not reloading the entire page is one of the main points of Ajax.
>
> If you want to reload the entire page (like with a redirect) and you're not handling that yourself in JavaScript I don't really see the point (in general; there are exceptions).
>
> You may want to read up on Ajax fundamentals; JJG's article is one of the more popular ones, even though people have been doing it for a decade+ now.
>
> http://www.adaptivepath.com/ideas/essays/archives/000385.php
>
> The Wikipedia article gives a shorter, higher-level overview. The second sentence may be informative:
>
> "With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page."
>
> http://en.wikipedia.org/wiki/AJAX
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_189488.ezm (zipped)
--- On Wed, 7/30/08, Nick Scavelli <nick.scavelli@(protected):
> I'm replying to this because it's somewhat related
> to an issue I'm having.

Not really :p

> Let's say I have the following control in my jsp:
> <sx:submit type="button" method="search" value="Search"
>        targets="resultsDiv" indicator="indicator"/>
>
> But let's say my session has timed out, and I need to redirect to the
> login page. In my circumstance the div is replaced by the login jsp,
> which just looks strange. What are the best practices with dealing with
> these situations using Ajax.

I'm not sure what the *best* practice is, but one solution is to write an interceptor that checks if a request is an XHR. If it is, and the session is gone (or whatever other criteria is necessary), send back a 302 and the name of a global result (that's what we've done here, anyway). Even though it's an XHR the browser will redirect before the request gets back to your code--in essence making the request non-back-channel anymore.

(I'm not entirely convinced that behavior is reasonable, but it's a browser thing, so hey.)

Dave


Attachment: user_189486.ezm (zipped)
Hi

When validation succeeds on my form, I still get returned to the input
page. My execute() method does not seem to be getting called even when
validation is OK.

This is my Action (no @Validation annotation after I read that was
deprecated)

=======================================================
  @Validations(visitorFields = {
    @VisitorFieldValidator(message = "Default message",
    fieldName = "surname",
    appendPrefix = false)
  })
  public String execute() {
 ...


  @RequiredStringValidator(message="Validation error",
key="validate.surname")
  public String getSurname() {
    return surname;
  }
 ...
=======================================================



This is my struts.xml snippet, with the correct result attributes

    <action name="login" method="execute" class="loginAction">
       <result name="success" type="tiles">home</result>
       <result name="input" type="tiles">welcome</result>
    </action>  

In the logs, when I enter an empty surname, I see "surname is invalid"
when I expect. The same message is not in the logs when I enter a valid
value, so I would expect it to then drop into my 'execute' method. But
it doesn't, it just returns to the 'input' page...

Any ideas?

Regards

Richard Gundersen


As a responsible corporate citizen, London Scottish Bank plc asks you to consider the environment before printing this email.

*** Disclaimer ***

This electronic communication is confidential and for the exclusive use of the addressee. It may contain private and confidential information. The information, attachments and opinions contained in this E-mail are those of its author only and do not necessarily represent those of London Scottish Bank PLC or any other members of the London Scottish Group.

If you are not the intended addressee, you are prohibited from any disclosure, distribution or further copying or use of this communication or the information in it or taking any action in reliance on it. If you have received this communication in error please notify the Information Security Manager at ISM@(protected).

We utilise virus scanning software but we cannot guarantee the security of electronic communications and you are advised to check any attachments for viruses. We do not accept liability for any loss resulting from any corruption or alteration of data or importation of any virus as a result of receiving this electronic communication.

Replies to this E-mail may be monitored for operational or business reasons. London Scottish Bank PLC is regulated by the Financial Services Authority.


London Scottish Bank plc, Registered Office: 201 Deansgate, Manchester M3 3NW Registered Number 973008 England.

Subsidiary Companies:-

London Scottish Finance Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered Number 233259 England.

London Scottish Broking Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered Number 230110 England.

London Scottish Invoice Finance Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered Number 2643766 England.

Robinson Way & Company Limited, Registered Office: 201 Deansgate, Manchester M3 3NW Registered Number 885896 England.

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.

Attachment: user_189503.ezm (zipped)
Gundersen, Richard wrote:
> Hi
>
> When validation succeeds on my form, I still get returned to the input
> page. My execute() method does not seem to be getting called even when
> validation is OK.
>
> This is my Action (no @Validation annotation after I read that was
> deprecated)
>
> =======================================================
>   @Validations(visitorFields = {
>      @VisitorFieldValidator(message = "Default message",
>      fieldName = "surname",
>      appendPrefix = false)
>   })
>   public String execute() {
>  ...
>
>
>   @RequiredStringValidator(message="Validation error",
> key="validate.surname")
>   public String getSurname() {
>      return surname;
>   }
>  ...
> =======================================================

Do you have a setSurname(String) method? Without it, Struts can't pass
the input data into your action.

> This is my struts.xml snippet, with the correct result attributes
>
>      <action name="login" method="execute" class="loginAction">
>         <result name="success" type="tiles">home</result>
>         <result name="input" type="tiles">welcome</result>
>      </action>  
>
> In the logs, when I enter an empty surname, I see "surname is invalid"
> when I expect. The same message is not in the logs when I enter a valid
> value, so I would expect it to then drop into my 'execute' method. But
> it doesn't, it just returns to the 'input' page...
>
> Any ideas?

If you do have the setter in your action and you're getting this, do you
have any action errors/messages showing up when you get returned to the
input page?

L.



Attachment: user_189487.ezm (zipped)
Hi all,

I have a multi-page form bean for a 2 step registration form. In the
second page I have a back button like this:

    <button name="my.company.package.BACK_BUTTON" type="submit">
       <bean:message key="prompt.back.button" />
    </button>

and in my action I check if it was pressed similarly to the cancel button:
....
    if (isCancelled(request)) {
       targetUrl = "goHome";
    } else if (isBack(request)) {
       targetUrl = "goRegisterOrg";
    } else {
.....
  private boolean isBack(HttpServletRequest request) {
    String back = (String)request.getParameter(EDConstants.BACK_BUTTON);

    return (back != null);
  }


My problem is, how do I disable validator from checking the form?
Currently the user presses the back
button and validation errors show up, so he has to enter some valid
values to go back. Any ideas?

Thanks
Dimitris

Attachment: user_189490.ezm (zipped)


Jeromy Evans - Blue Sky Minds wrote:
>
> Andy Law wrote:
>>
>> e.g.
>> /foo/Action1.action runs action1 passing in 'foo' and /bar/Action1.action
>> runs the same action passing in 'bar'.
>>
>> How should I code/configure/build this kind of thing.
>>  
>
>
> In Struts 2.0.x, you may be able to use wildcards in the namespace
> depending on how many variations you need.
>
> http://struts.apache.org/2.0.11.2/docs/wildcard-mappings.html
>
> In Struts 2.0.x, you may also be able to use the RestfulActionMapper to
> pass simple properties to your action through the path.
>
> http://struts.apache.org/2.0.11.2/docs/restfulactionmapper.html
>
> Use it with a CompositeActionMapper.
>
> In Struts 2.1.x, use the NamedVariablePatternMatcher to pass parameters
> through the namespace, as described in this thread:
> http://www.nabble.com/REST-plugin-URL-syntax-td17855192i20.html
>


Jeromy,

That's enormously helpful - thanks.

A short follow-up. Can you point me towards a description of where/when the
Action object gets created and where Interceptors fit into the process.

I need to understand how I'm going to get the leading part of the URL into
the action object and my head really, really hurts right now... :o}. I'm
wondering if an interceptor might be a better, more understandable (to me)
option?

If I'm reading things right as of now, the ActionMapper route will fire (and
complete) before the Action object is created (since the ActionMapper
decides *which* Action gets created) so my options there are to put the
details of what I find in the URL path into the request object where it can
be pulled by the Action (which makes testing slightly harder), whereas an
Interceptor allows me to just magic the details into the Action. On the
other hand, the Interceptor requires a signature on the Action which could
be overruled with a Parameter in the URL?

Please tell me if I'm talking nonsense. I'm just kind of thinking out loud
while I try to get a feel for the best way to do what I need.


Later,

Andy Law

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


Attachment: user_189505.ezm (zipped)
Andy Law wrote:
>
>
>
> Jeromy,
>
> That's enormously helpful - thanks.
>
> A short follow-up. Can you point me towards a description of where/when the
> Action object gets created and where Interceptors fit into the process.
>
>  

The architect's guide is a good place to start.

http://struts.apache.org/2.0.11.2/docs/big-picture.html

There's nothing better than a good book though.

> I need to understand how I'm going to get the leading part of the URL into
> the action object and my head really, really hurts right now... :o}. I'm
> wondering if an interceptor might be a better, more understandable (to me)
> option?
>
> If I'm reading things right as of now, the ActionMapper route will fire (and
> complete) before the Action object is created (since the ActionMapper
> decides *which* Action gets created) so my options there are to put the
> details of what I find in the URL path into the request object where it can
> be pulled by the Action (which makes testing slightly harder), whereas an
> Interceptor allows me to just magic the details into the Action. On the
> other hand, the Interceptor requires a signature on the Action which could
> be overruled with a Parameter in the URL?
>
>  

Creating a custom interceptor or custom action mapper is a fine way to
go about it.
The ParametersInterceptor is responsible for setting properties of your
action from params in the request.
There's also two other ParametersInterceptor variations; one that sets
static parameters defined in struts.xml, and another that sets
parameters created by the ActionMapper.

You could also create your own interceptor that checks if your action
implements a particular interface, and if so, extract some information
from the request and sets a property.

The plugins I mentioned previously do that for you in their own ways but
if none are suitable then I'd probably create a custom ActionMapper that
exends the default but also looks for that param in the URI and returns
it in the parameter map of the ActionMapping.

Hope that makes sense.
regards,
Jeromy Evans





Attachment: user_189492.ezm (zipped)
(Using Struts 2.1.2)

I have a little "widget" (for want of a better word) which gets activated on
most pages by a call to:

  <s:action name="myWidget" namespace="/widgets" executeResults="true" />

the result of that action being a small JSP that will sit snuggly inside its
little box on the overall page. That little widget is, in effect,
independent and clueless of its surroundings, and very happy for it all.
The sole job of the MyWidgetAction is gather the latest results and make
these available to the widget through a getResults() method. Here is its
original entry in struts.xml:

  <package name="widgets" extends="default" abstract="false"
namespace="/widgets">
    <action name="myWidget" class="com.mysite.MyWidgetAction">
       <result>widget.jsp</result>
    </action>
  </package>


The problem occurs when the widget appears on a JSP page with a form. When
the user submits that form, if the ensuing action generates the INPUT result
(say, because there was a problem with the content of the form), the JSP
form page gets redisplayed, but it's clear that MyWidgetAction is not called
anew, and Struts2 complains:

  ERROR ActionComponent:28 - Could not execute action: /widgets/myWidget
  No result defined for action com.infloox.tango.teaser.TeaserAction and
result input

If, on the other hand, I change the widget's result mapping (so as to catch
results under any name):

    <action name="myWidget" class="com.mysite.MyWidgetAction">
       <result name="*">widget.jsp</result>
    </action>

I then get the following error:

  WARN OgnlValueStack:50 - Caught an exception while evaluating
expression 'results' against value stack
  Caught an Ognl exception while getting property results - Class:
ognl.OgnlRuntime
  File: OgnlRuntime.java
  Method: getMethodValue
  Line: 935 - ognl/OgnlRuntime.java:935:-1
  ...
  Caused by: ognl.OgnlException: results [java.lang.NullPointerException]
  ...

("results" being the property on MyWidgetAction (with a getResults() getter)
which gets called by widget.jsp.)

I suppose one solution would be to put the results of MyWidget on the
session; on an INPUT result, at least something would get displayed (even
though not the latest results). But using the session like that seems to go
against Struts2's philosophy...
Another (prospective) option would be to involve AJAX over this question.

Alternatively, is there a way to force a re-execution of that specific
<s:action name="widget">?

Attachment: user_189493.ezm (zipped)

Hello Everyone,

Got a quick question regarding the streaming of a JFreeChart (or any image)
and how to be able to handle it on a jsp. I have create a servlet that will
stream out an image to the jsp using a syntax similar to (in my struts.xml):

   <action name="testChart"
     class="TestBarChart">
     <result name="success" type="chart">
       350
       300
     </result>
   </action>

So if I, in my html, created an img tag such that testChart.action , it
will correctly create the chart. My problem arises when I am using it under
a dynamic context. For example, if initially I submit a form button
(theme="ajax" targets="divTarget") then it would render new data and an
initial image.

If I submit the form again with different user input the data would change
but the image is still the same. I assume it is the same buffered image that
it first loaded, but the action itself will never get reloaded. The action
would not get executed at all.

My question is whether there is a way I can manually force the img tag to
invoke the action itself.

Thanks for any input
--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_189494.ezm (zipped)

Hello Everyone,

Got a quick question regarding the streaming of a JFreeChart (or any image)
and how to be able to handle it on a jsp. I have create a servlet that will
stream out an image to the jsp using a syntax similar to (in my struts.xml):

   <action name="testChart"
     class="TestBarChart">
     <result name="success" type="chart">
       350
       300
     </result>
   </action>

So if I, in my html, created an img tag such that <img
src="testChart.action"/ , it will correctly create the chart. My problem
arises when I am using it under a dynamic context. For example, if
initially I submit a form button (theme="ajax" targets="divTarget") then it
would render new data and an initial image.

If I submit the form again with different user input the data would change
but the image is still the same. I assume it is the same buffered image that
it first loaded, but the action itself will never get reloaded. The action
would not get executed at all.

My question is whether there is a way I can manually force the img tag to
invoke the action itself.

Thanks for any input
--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_189495.ezm (zipped)
In Struts2, what is the equivalent of Struts1's "errorStyleClass" parameter
of <html:text> tag?

In other words, how can I control the CSS style of a <s:textfield> when
there is an error over that field?

Attachment: user_189496.ezm (zipped)
In your action set the fieldError:
addFieldError("someField", "someText")

in your JSP:
<s:textfield name="someField" cssErrorClass="someClass"/>

Thanks,
-RD

-----Original Message-----
From: Pierre Thibaudeau [mailto:pierre.thibaudeau@(protected)]
Sent: Wednesday, July 30, 2008 3:31 PM
To: Struts Users Mailing List
Subject: [S2] error style on s:textfield

In Struts2, what is the equivalent of Struts1's "errorStyleClass"
parameter of <html:text> tag?

In other words, how can I control the CSS style of a <s:textfield> when
there is an error over that field?

Attachment: user_189497.ezm (zipped)
2008/7/30 Dasgupta, Ranjan <Ranjan.Dasgupta@(protected)>

> In your action set the fieldError:
> addFieldError("someField", "someText")
>
> in your JSP:
> <s:textfield name="someField" cssErrorClass="someClass"/>
>

Thank you, Ranjan!

The "cssErrorClass" parameter was forgotten from the tag reference guides.
See for example:
http://struts.apache.org/2.1.2/docs/textfield.html

Attachment: user_189498.ezm (zipped)

First I thought the problem was from ACEGI that I recently added to the
project. So I took all of it out .However I encountered the same problem as
above in IE. Then I thought the problem could be some leak in display tag .
So i swithced back to normal table and the same thing again.

So I realize that a Tabbed Panel inside a Tabbed Panel does not work if you
click on the parent tab 5 to 6 times. Closing the IE window and opening it
up works again for the next few clicks. It seems it has stored something in
the session or something and is not cleaning it up.

After I get the error below
Error loading
'/Dashboard/ViewOMTable.action?dojo.preventCache=1217258686015' (200 OK)
none of the tabs are working and they all show the error above.

It could be an IE issue cause its working fine in FireFox.

Any work arounds or ideas will be greatly appreciated. Thanks.




dynamicd wrote:
>
> Hi,
>
> I am new to Struts2 and I am having a problem displaying content with IE.
> It works fine in Firefox.
> I am using Struts2, Acegi for login, Hibernate for ORM and struts2 ajax
> tags for display
>
> I have a parent tabbed panel and a child tabbed panel.
> Once I login everything works fine however after a few clicks around I get
> the following error.
>
> Error loading
> '/Dashboard/ViewOMTable.action?dojo.preventCache=1217258686015' (200 OK)
>
> I am not sure why it is working when I log in and not after a few clicks.
> Again it works as expected in Firefox.
>
> Myjsp looks like this
>
> Parent tab has the following tab
>
>  <authz:authorize ifAnyGranted="ROLE_ADMINISTRATOR"> /** this is for the
> Acegi stuff */
>    <s:url id="listOM" value="/Dashboard/ViewManagedEntities.action" />
>     <s:div
>     id="OM"
>     label ="Operations Manager"
>     theme="ajax"
>     href="%{listOM}"
>     autoStart="false"
>     refreshOnShow="true"
>     errorText="Unable to retrieve data!">
>   </s:div>
> </authz:authorize>
>
> This will get the child jsp which is below which is also tabbed panel
>
>
> <s:head theme="ajax" debug="true"/>
> <s:div id="OMpage">
>  <s:tabbedPanel id="insideOMTab" selectedTab="allOM">
>
>  <s:url id="allOM" action="ViewOMTable.action" />
>     <s:div
>     id="allOM"
>     label ="LIST"
>     theme="ajax"
>     href="%{allOM}"
>     autoStart= "false"
>     refreshOnShow="true"
>     >
>   </s:div>    
>  
>    
>   <s:url id="addOM" action="showaddOMform" />
>     <s:div
>     id="addOM"
>     label ="ADD"
>     theme="ajax"
>     href="%{addOM}"
>     autoStart= "false"
>     refreshOnShow="true"
>     >
>   </s:div>    
>  
>    </s:tabbedPanel>
>
>   </s:div>
>
>
> Any help is greatly appreciated
>
>
>
>
>
>

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


Attachment: user_189499.ezm (zipped)
cpanon wrote:
> Hello
> I am having a difficult time designing and implementing an interaction of displaying and accepting user input of multiple records at once. I can create a collection of records, but records are complex, composed of other objects that are themselves composed of text strings that I want rendered as either simple html input boxes, checkboxes or radio. I have a sense that I need to use the iterate to get iterate over the total collection, but how do I record by record render the html input elements. Furthermore what do these look like to the action that will receive the post? A simpler version of this is being done on shopping carts a checkbox on each line, but that may be hard coded. Is the way I need it even possible with struts 1.1?


Without knowing anything about what your data structures look like, it's
hard to offer specific advice; are you working directly with record
sets? with business model classes persisted via JPA? etc.

At a high level, what you want to do is certainly possible. How easy it
will be will depend on what your data model looks like and whether you
have the flexibility to change it.

I would suggest you start out by reading up on how Struts manages the
mapping between model data and HTML forms, and especially how data
conversion works. Then build a simplified prototype that works with a
minimal data model and build up from there until you have something
representative of the end goal.

It will be easier to get help when you have specific questions you can ask.

L.


Attachment: user_189500.ezm (zipped)
ManiKanta G wrote:
> Hi,
>
> How can I redirect to another page after stream result. For example
> redirecting to another page saying successfully downloaded the file or
> adding some action message and redirecting to the same page.

You can't; there can only be one response to an HTTP request. The same
question was asked yesterday; see the thread 'ServletOutputStream' in
the archives.

L.


Attachment: user_189501.ezm (zipped)
Ylva Degerfeldt wrote:
> Hi everyone,
>
> I'm using Struts 1.2 (bundled with NetBeans 5.5.1) and I've noticed
> that I can't iterate through a java.util.Set using the logic:iterate
> tag.
> The code that I've tried:
>
> <logic:iterate collection = "skillsFound" id= "thisSkill" scope = "session">
>
> I get this exception: javax.servlet.ServletException:
> javax.servlet.jsp.JspException: Cannot create iterator for this
> collection
>
> Does anyone know if this is a bug of Struts 1.2 and if there's a later
> version (not Struts 2) where it's been fixed?
>
> I'd really appreciate an answer to this!
>
> Thanks in advance!
>
> /Ylva

Sets are unordered, so I believe both Struts's iterate and JSTL forEach
tags treat them as non-iterable, even though they do implement
Collection. If you can expose skillsFound.iterator() as a scripting
variable or page/request scoped attribute to pass into logic:iterate
that might work.

L.


Attachment: user_189504.ezm (zipped)
Hi all,

Was really not sure which mailing list to post to ...

I have a java application that uses struts 2 (actions, etc).
Every time I access a page (which goes through an action), my browser gets
to that page, but then it "skips" (for want of a better term) onto a blank
page (with the URL intact).

I am using JBoss 4.2.2 GA.

This problem only occurs with FireFox version 3.0.1 (the latest version).
It does not occur with FireFox version 2.0.0.16, Internet Explorer or
Safari.

Has anyone had this problem?

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