Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

user Digest 8 Feb 2008 04:04:52 -0000 Issue 7853

user-digest-help

2008-02-07


Author LoginPost Reply

user Digest 8 Feb 2008 04:04:52 -0000 Issue 7853

Topics (messages 182350 through 182379):

Is Multiple Forms(s:form) in one Jsp possible?
 182350 by: Thomas Ramapuram
 182351 by: Thomas Ramapuram
 182355 by: Dave Newton
 182378 by: Jeromy Evans
 182379 by: Dave Newton

Re: STRUTS 2: File tag problem
 182352 by: Dave Newton

Re: Struts2 sesionExpired page
 182353 by: Dave Newton

Re: Struts2, collection of objects and JSP
 182354 by: Dave Newton
 182359 by: Piotr Falenczyk

Multiple submit buttons in a single JSP
 182356 by: Johnson nickel
 182357 by: Lukasz Lenart

Re: [struts] Is Multiple Forms(s:form) in one Jsp possible?
 182358 by: Dale Newfield

[s2] handling "Unable to instantiate action" exception
 182360 by: Laszlo Borsos

servletOutputStream in S2 action
 182361 by: bhaarat Sharma
 182362 by: Mike Jennings
 182363 by: bhaarat Sharma
 182365 by: bhaarat Sharma

Re: [struts] servletOutputStream in S2 action
 182364 by: Dale Newfield
 182366 by: Dale Newfield
 182367 by: bhaarat Sharma
 182368 by: Dale Newfield
 182369 by: bhaarat Sharma
 182370 by: Dale Newfield
 182372 by: bhaarat Sharma
 182374 by: Dale Newfield

File upload issues when maxFileSize is exceeded.
 182371 by: Adam Gordon
 182373 by: Martin Gainty
 182375 by: Dave Newton

Dynamic indexed field name in validation?
 182376 by: Hodgins, Grant

open new window using Struts action
 182377 by: jeppy

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_182350.ezm (zipped)
Hi,
I just wanted to know if it is possible to have multiple s:form in one
jsp. Each of the forms submit to a diffrent action.

The problem I faced is that. If I place multiple forms in one jsp. The
initials forms closing tags are commented out when the tag is rendered.
Is this expected behaviour or is it a bug.

Thanks in advance.
Regards,
Thomas Ramapuram.


Attachment: user_182351.ezm (zipped)
Hi,
I just wanted to know if it is possible to have multiple s:form in one
jsp. Each of the forms submit to a diffrent action.

The problem I faced is that. If I place multiple forms in one jsp. The
initials forms closing tags are commented out when the tag is rendered.
Is this expected behaviour or is it a bug.

Thanks in advance.
Regards,
Thomas Ramapuram.


Attachment: user_182355.ezm (zipped)
--- Thomas Ramapuram <thomas.ramapuram@(protected):
> I just wanted to know if it is possible to have multiple s:form in one
> jsp. Each of the forms submit to a diffrent action.
>
> The problem I faced is that. If I place multiple forms in one jsp. The
> initials forms closing tags are commented out when the tag is rendered.
> Is this expected behaviour or is it a bug.

I can't reproduce this; I have many pages with multiple forms.

Including a source code snippet might be helpful.

Dave


Attachment: user_182378.ezm (zipped)

Dave Newton wrote:
> --- Thomas Ramapuram <thomas.ramapuram@(protected):
>  
>> I just wanted to know if it is possible to have multiple s:form in one
>> jsp. Each of the forms submit to a diffrent action.
>>
>> The problem I faced is that. If I place multiple forms in one jsp. The
>> initials forms closing tags are commented out when the tag is rendered.
>> Is this expected behaviour or is it a bug.
>>  
>
> I can't reproduce this; I have many pages with multiple forms.
>
> Including a source code snippet might be helpful.
>
> Dave
>
>
>  
The commenting effect is something one of the browsers does when viewing
invalid html (forget which browser). It comments out the html for nodes
that were impossible to include in the DOM. I've seen it when forms are
accidentally nested as the OP must have done.


Attachment: user_182379.ezm (zipped)
--- Jeromy Evans <jeromy.evans@(protected):
> The commenting effect is something one of the browsers does when viewing
> invalid html (forget which browser). It comments out the html for nodes
> that were impossible to include in the DOM. I've seen it when forms are
> accidentally nested as the OP must have done.

Oh, interesting; I've never seen that.

This, of course, leads to the obvious conclusion that my HTML is always
perfect.

On a related note, watch for my auction of my bridge on e-bay Real Soon Now
(tm).

Dave


Attachment: user_182352.ezm (zipped)
--- mgainty@(protected):
>   private String fileName;   //this is the FULL pathname with filename

Depending on the browser this may or may not have the full pathname.

Dave



Attachment: user_182353.ezm (zipped)
In addition to the other suggestions posted you can also call the request's
isValidSessionId() method (or something like that).

Dave

--- "jignesh.patel" <jigneshd@(protected):

>
> Hi,
>   I am having struts2 application with hibernate + mysql.I want to create
> web app session Expired page,but i am not able to detect weather my
> application session expired or not.
>
> I have given session time out to 1 min also but it still displays active
> session.
> <session-config>
>  <session-timeout>1</session-timeout>
> </session-config>
>
> My SessionChecking interceptor looks like:-
>
> public class SessionExpired implements Interceptor {
>   public void destroy() {
>  LOG.info("..............destroy");
>   }
>
>   public void init() {
>  LOG.info("..............init");
>  }
>  
>   public String intercept(ActionInvocation actionInvocation) throws
> Exception {
>  Map session = actionInvocation.getInvocationContext().getSession();
>  if(session == null) {
>     LOG.info("..............interce if");
>  }
>  else {
>     LOG.info("..............interce else");
>  }
>  return actionInvocation.invoke();
>   }
> }
>
> After 1..2...3...5 min it still logging ("..............interce else").
>
> Do anyone know how can i detect my application session time out or not ?
>
> Thanks & regards
> jignesh
> --
> View this message in context:
> http://www.nabble.com/Struts2-sesionExpired-page-tp15328299p15328299.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_182354.ezm (zipped)
Piotr Falenczyk <pfal@(protected):
> I need to display all the names of Imports, and allow to edit every one of
> them in one page. What I do now is somethin like that ion JSP. Displaying
> values work just fine, but I canno't change them (not stored back in the
> session)
>
> <s:iterator value="imports">
>  <s:textfield name="name" />
>  </br>
> <s:iterator/>

One way is to the "status" attribute to your <s:iterator...> tag and use it
in your <s:textfield.../> tag as part of the name:

<s:iterator value="imports" status="stat">
<s:textfield name="name[%{#stat.index}]"/>
</s:iterator>

that as the index in your <s:textfield.../>'s name value. (The syntax may be
a bit off, but that's the idea.)

Dave



Attachment: user_182359.ezm (zipped)



newton.dave wrote:
>
> Piotr Falenczyk <pfal@(protected):
>> I need to display all the names of Imports, and allow to edit every one
>> of
>> them in one page. What I do now is somethin like that ion JSP. Displaying
>> values work just fine, but I canno't change them (not stored back in the
>> session)
>>
>> <s:iterator value="imports">
>>  <s:textfield name="name" />
>>  </br>
>> <s:iterator/>
>
> One way is to the "status" attribute to your <s:iterator...> tag and use
> it
> in your <s:textfield.../> tag as part of the name:
>
> <s:iterator value="imports" status="stat">
>  <s:textfield name="name[%{#stat.index}]"/>
> </s:iterator>
>
> that as the index in your <s:textfield.../>'s name value. (The syntax may
> be
> a bit off, but that's the idea.)
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

Thanks, that solved the problem.

Dave saved my day.

Regards

Piotr

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


Attachment: user_182356.ezm (zipped)

Hi all,

   In my JSP, i have three submit buttons, i want to know which button
user has clicked.

I tried from this site,
http://struts.apache.org/2.x/docs/html-form-buttons-howto.html
http://struts.apache.org/2.x/docs/html-form-buttons-howto.html
It's not working.

       Give me some ideas, i have added my code,


   public String execute() {
    if (buttonOnePressed) {
       message = "You pressed the first button";
      Save();
     
    } else if (buttonTwoPressed) {
       Update();
       message = "You pressed the second button";
    }

    else if (buttonThreePressed) {
      Show();
       message = "You pressed the second button";
    }
    else {
       return ERROR;
    }
    return SUCCESS;
  }

In My Struts.xml file,

<action name="user_details2" class="com.user_details">
       <result name="input">/JSP/user_details.jsp</result>
     <result name="success">/JSP/user_details.jsp</result>
     <result name="error">/JSP/user_details.jsp</result>
     
   </action>

In Jsp,

<input type="submit" name="buttonOnePressed" value="Save"/>
<input type="submit" name="buttonTwoPressed" value="Update"/>
<input type="submit" name="buttonThreePressed" value="Show"/>
--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_182357.ezm (zipped)
Hi,

You can use
<s:submit value="Save" method="save"/>
<s:submit value="Update" method="update"/>
<s:submit value="Show" method="show"/>

and Action class with three methods, the same like execute()

http://struts.apache.org/2.x/docs/submit.html


Regards
--
Lukasz

http://www.linkedin.com/in/lukaszlenart

Attachment: user_182358.ezm (zipped)
Thomas Ramapuram wrote:
> I just wanted to know if it is possible to have multiple s:form in one
> jsp. Each of the forms submit to a diffrent action.

Just make sure they're not nested inside one another, and that no two
elements on the rendered page have the same id attribute.

-Dale

Attachment: user_182360.ezm (zipped)

I use wildcard mappings and Spring integration.
When a bad url is entered, no Spring bean is mapped and it results in an
exception page. I would like to swap this to a nice "Sorry, this page does
not exist" message.

However, the Exception Interceptor does not catch this, probably because it
happens before the chain of interceptors.
How can I solve this?

kuvera


-----
http://javatar.hu Java EE programming
--
Sent from the Struts - User mailing list archive at Nabble.com.


Attachment: user_182361.ezm (zipped)
Hello

I have a S2 action working perfectly fine. But on one page of my web
App I would like the user to be able to download report in Excel. We
have this functionality in other pages as well but they arent using S2
and are doing this via a custom servlet which has doGet doPost and
processRequest methods.

Inside the processRequest..they do bunch of stuff to get the excel
read and in the end do this:

  ServletOutputStream stream = null;
  String fileName = \"something\";


     response.addHeader(\"Content-Disposition\", \"attachment;
filename=\" + fileName);
     response.setContentType(\"application/vnd.ms-excel\");
     stream = response.getOutputStream();
     wb.write(stream);

this is a void method.

My question is, since in my case I already have a S2 action..I dont
want to make a new servlet to do this.

How can i do the same in my execute method for S2?? what should the
execute method return? because when user clicks get Excel link..the
page stays the same but just the user is presented with open/save
dialog.

Woudl appreciate any help.

Attachment: user_182362.ezm (zipped)
You can do this by creating a custom result type.

A example of a custom result type for streaming images from a action to
a img tag is here.

http://struts.apache.org/2.x/docs/how-can-we-display-dynamic-or-static-images-that-can-be-provided-as-an-array-of-bytes.html

You can use this as a example, but will probably have to have a modify
it slightly so that your action will have a getter and setter to pass a
output stream to the result type. In the result type you can write the
output stream to the response output stream.

Mike Jennings

bhaarat Sharma wrote:
> Hello
>
> I have a S2 action working perfectly fine. But on one page of my web
> App I would like the user to be able to download report in Excel. We
> have this functionality in other pages as well but they arent using S2
> and are doing this via a custom servlet which has doGet doPost and
> processRequest methods.
>
> Inside the processRequest..they do bunch of stuff to get the excel
> read and in the end do this:
>
>    ServletOutputStream stream = null;
>    String fileName = \"something\";
>
>
>       response.addHeader(\"Content-Disposition\", \"attachment;
> filename=\" + fileName);
>       response.setContentType(\"application/vnd.ms-excel\");
>       stream = response.getOutputStream();
>       wb.write(stream);
>
> this is a void method.
>
> My question is, since in my case I already have a S2 action..I dont
> want to make a new servlet to do this.
>
> How can i do the same in my execute method for S2?? what should the
> execute method return? because when user clicks get Excel link..the
> page stays the same but just the user is presented with open/save
> dialog.
>
> Woudl appreciate any help.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com


Attachment: user_182363.ezm (zipped)
I was trying stuff out and i hve got it working perfectly.

Only thing is my that my execute is returning a SUCCESS when
everything is done. However I do not have any <result> in my
struts.xml for this action. since the user shouldnt be moved to
another page.

Now I am able to see open /save dialog box as well and excel opens
fine too but in my logs i ssee the following exception..


StandardWrapperValve[default]: Servlet.service() for servlet default
threw exception
java.lang.IllegalStateException
    at org.apache.coyote.tomcat5.CoyoteResponseFacade.sendError (CoyoteResponseFacade.java:390)
    at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute (ServletDispatcherResult.java:127)
    at org.apache.struts2.dispatcher.StrutsResultSupport.execute (StrutsResultSupport.java:178)
    at com.opensymphony.xwork2.DefaultActionInvocation.executeResult (DefaultActionInvocation.java:348)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke (DefaultActionInvocation.java:253)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept (DefaultWorkflowInterceptor.java:221)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (MethodFilterInterceptor.java:86)


..what should my execute method be returning?



On 2/7/08, Mike Jennings <gjennings@(protected):
You can do this by creating a custom result type.
>
> A example of a custom result type for streaming images from a action to
> a img tag is here.
>
> http://struts.apache.org/2.x/docs/how-can-we-display-dynamic-or-static-images-that-can-be-provided-as-an-array-of-bytes.html
>
> You can use this as a example, but will probably have to have a modify
> it slightly so that your action will have a getter and setter to pass a
> output stream to the result type. In the result type you can write the
>  output stream to the response output stream.
>
> Mike Jennings
>
> bhaarat Sharma wrote:
> > Hello
> >
> > I have a S2 action working perfectly fine. But on one page of my web
> > App I would like the user to be able to download report in Excel. We
> > have this functionality in other pages as well but they arent using S2
> > and are doing this via a custom servlet which has doGet doPost and
> > processRequest methods.
> >
> > Inside the processRequest..they do bunch of stuff to get the excel
> > read and in the end do this:
> >
> >    ServletOutputStream stream = null;
> >    String fileName = \\\"something\\\";
> >
> >
> >       response.addHeader(\\\"Content-Disposition\\\", \\\"attachment;
> > filename=\\\" + fileName);
> >       response.setContentType(\\\"application/vnd.ms-excel\\\");
> >       stream = response.getOutputStream();
> >       wb.write(stream);
> >
> > this is a void method.
> >
> > My question is, since in my case I already have a S2 action..I dont
> > want to make a new servlet to do this.
> >
> > How can i do the same in my execute method for S2?? what should the
> > execute method return? because when user clicks get Excel link..the
> > page stays the same but just the user is presented with open/save
> > dialog.
> >
> > Woudl appreciate any help.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
> > --------------------------------
> > Spam/Virus scanning by CanIt Pro
> >
> > For more information see
> > http://www.kgbinternet.com/SpamFilter.htm
> >
> > To control your spam filter, log in at
> > http://filter.kgbinternet.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_182365.ezm (zipped)
just read the link you sent.

I cant make my execute method void because it is being used for
another page which requires it to send something back. :(

Attachment: user_182364.ezm (zipped)
Mike Jennings wrote:
> You can do this by creating a custom result type.

Or you can use a result type that's already provided that does exactly
what you need.

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

>> How can i do the same in my execute method for S2?? what should the
>> execute method return? because when user clicks get Excel link..the
>> page stays the same but just the user is presented with open/save
>> dialog.

What the browser does with the data (attempt to display it/save it) is
determined by the "contentDisposition" You want that to read something
like: "attachment;filename=${something.dynamic}.xls"

-Dale

Attachment: user_182366.ezm (zipped)
bhaarat Sharma wrote:
> ..what should my execute method be returning?

As always, it should return the name of the appropriate result (in this
case, the name of the result of type "stream").

-Dale

Attachment: user_182367.ezm (zipped)
I think its better if i post some code.

This is the action mapping for
 <action name=\"accessRequestReportResult\"
class=\"action.reports.AccessRequestReportResult\">
  <result name=\"showReport\">/useradmin/AccessRequestReport.jsp</result>
  <result name=\"failure\">login.jsp</result>
  <result></result><!--i was trying this but didnt work-->
 </action>


this is my execute method:


  public String execute() throws IOException, ServletException {

    //we dont enter here for excel
     if (getServletRequest().getParameter(\"isExcel\")==null)
    {
       setData(getActionValue());
       return \"showReport\";
    }
   //enter here for excel
    else
    {
       setData(getServletRequest().getParameter(\"action\"));
       excelReport();//this does all the excel stuff and writes
to the HttpServletResponse.
       return \"stream\";//i also tried return SUCCESS but even
then got illegalStateException
    }

  }

Everything works dandy but i have an IllegalStateException in my logs.
saying no result defined for \"stream\"...

is there a workaround here...:(







On 2/7/08, Dale Newfield <Dale@(protected):
bhaarat Sharma wrote:
> > ..what should my execute method be returning?
>
> As always, it should return the name of the appropriate result (in this
> case, the name of the result of type \"stream\").
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_182368.ezm (zipped)
bhaarat Sharma wrote:
> I think its better if i post some code.
>
> This is the action mapping for
>   <action name=\"accessRequestReportResult\"
> class=\"action.reports.AccessRequestReportResult\">
>   <result name=\"showReport\">/useradmin/AccessRequestReport.jsp</result>
>   <result name=\"failure\">login.jsp</result>
    <result name="excel" type="stream">
     <param name="contentType">application/vnd.ms-excel</param>
     <param name="inputName">excelStream</param>
     <param
name="contentDisposition">attachment;filename="${excelFilename}"</param>
     <param name="bufferSize">1024</param>
     <!-- if you know the content length you should add the
contentLength parameter -->
   </result>
>   </action>


> this is my execute method:
>
>
>   public String execute() throws IOException, ServletException {
>
>      //we dont enter here for excel
>       if (getServletRequest().getParameter(\"isExcel\")==null)
>      {
>         setData(getActionValue());
>         return \"showReport\";
>      }
>     //enter here for excel
>      else
>      {
         do whatever it takes to set the action up so that when
getExcelStream() is called the appropriate stream is returned, and when
getExcelFilename() is called, the appropriate filename is returned.
         return "excel";
>      }
>
>   }

-Dale

Attachment: user_182369.ezm (zipped)
Thanks for that. that gives me a better idea to go about things + i
didnt know we can call methods from struts.xml


i implemented this but am getting this error

java.lang.ClassCastException: org.apache.coyote.tomcat5.CoyoteOutputStream
 org.apache.struts2.dispatcher.StreamResult.doExecute (StreamResult.java:182)
 org.apache.struts2.dispatcher.StrutsResultSupport.execute (StrutsResultSupport.java:178)
 com.opensymphony.xwork2.DefaultActionInvocation.executeResult (DefaultActionInvocation.java:348)
 com.opensymphony.xwork2.DefaultActionInvocation.invoke (DefaultActionInvocation.java:253)



my getExcelStream looks like this

  public ServletOutputStream getExcelStream()
  {
    return this.stream;
  }

excelDownload method has this that sets up the stream.
     stream = response.getOutputStream();
     wb.write(stream);

wb is the worksheet...



On 2/7/08, Dale Newfield <Dale@(protected):
bhaarat Sharma wrote:
> > I think its better if i post some code.
> >
> > This is the action mapping for
> >   <action name=\\\"accessRequestReportResult\\\"
> > class=\\\"action.reports.AccessRequestReportResult\\\">
> >   <result name=\\\"showReport\\\">/useradmin/AccessRequestReport.jsp</result>
> >   <result name=\\\"failure\\\">login.jsp</result>
>     <result name=\"excel\" type=\"stream\">
>       <param name=\"contentType\">application/vnd.ms-excel</param>
>       <param name=\"inputName\">excelStream</param>
>       <param
> name=\"contentDisposition\">attachment;filename=\"${excelFilename}\"</param>
>       <param name=\"bufferSize\">1024</param>
>       <!-- if you know the content length you should add the
> contentLength parameter -->
>     </result>
> >   </action>
>
>
> > this is my execute method:
> >
> >
> >   public String execute() throws IOException, ServletException {
> >
> >      //we dont enter here for excel
> >       if (getServletRequest().getParameter(\\\"isExcel\\\")==null)
> >      {
> >         setData(getActionValue());
> >         return \\\"showReport\\\";
> >      }
> >     //enter here for excel
> >      else
> >      {
>           do whatever it takes to set the action up so that when
> getExcelStream() is called the appropriate stream is returned, and when
> getExcelFilename() is called, the appropriate filename is returned.
>           return \"excel\";
> >      }
> >
> >   }
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_182370.ezm (zipped)
bhaarat Sharma wrote:
> Thanks for that. that gives me a better idea to go about things + i
> didnt know we can call methods from struts.xml

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

describes how that result works, stating taht the "inputName" parameter
is "the name of the InputStream property from the chained action
(default = inputStream)"

The filename expression works because this result extends
http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/StrutsResultSupport.html
which allows for ognl expressions in result parameters (if the parse
parameter is true, which is the default).

> java.lang.ClassCastException: org.apache.coyote.tomcat5.CoyoteOutputStream
>  org.apache.struts2.dispatcher.StreamResult.doExecute (StreamResult.java:182)
>  org.apache.struts2.dispatcher.StrutsResultSupport.execute (StrutsResultSupport.java:178)
>  com.opensymphony.xwork2.DefaultActionInvocation.executeResult (DefaultActionInvocation.java:348)
>  com.opensymphony.xwork2.DefaultActionInvocation.invoke (DefaultActionInvocation.java:253)

That's saying that it can't cast a "CoyoteOutputStream" as an
InputStream. The result will manage the output to the client. You
shouldn't need to deal with the response or the servlet. What you need
to do is provide the result with a source of the data to be sent to the
client.

Note that every call to getExcelStream needs to return an independent
InputStream. For example, when you don't tell the result the
contentLength it has no choice but to step through the entire stream to
find the length, then it'll ask for a new stream to actually pull the
data out of to send to the client.

-Dale

Attachment: user_182372.ezm (zipped)
>What you need to do is provide the result with a source of the >data
to be sent to the client.

and that data has to be in java.io.InputStream??

even if my getExcelStream method returns java.io.OutputStream...I
still get an exception

so what TYPE of data should getExcelStream be returning :(

seems i am so close to fixing this....


On 2/7/08, Dale Newfield <Dale@(protected):
bhaarat Sharma wrote:
> > Thanks for that. that gives me a better idea to go about things + i
> > didnt know we can call methods from struts.xml
>
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/StreamResult.html
>
> describes how that result works, stating taht the \"inputName\" parameter
> is \"the name of the InputStream property from the chained action
> (default = inputStream)\"
>
> The filename expression works because this result extends
> http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/StrutsResultSupport.html
> which allows for ognl expressions in result parameters (if the parse
> parameter is true, which is the default).
>
> > java.lang.ClassCastException: org.apache.coyote.tomcat5.CoyoteOutputStream
> >     org.apache.struts2.dispatcher.StreamResult.doExecute (StreamResult.java:182)
> >     org.apache.struts2.dispatcher.StrutsResultSupport.execute (StrutsResultSupport.java:178)
> >     com.opensymphony.xwork2.DefaultActionInvocation.executeResult (DefaultActionInvocation.java:348)
> >     com.opensymphony.xwork2.DefaultActionInvocation.invoke (DefaultActionInvocation.java:253)
>
> That\'s saying that it can\'t cast a \"CoyoteOutputStream\" as an
> InputStream. The result will manage the output to the client. You
> shouldn\'t need to deal with the response or the servlet. What you need
> to do is provide the result with a source of the data to be sent to the
> client.
>
> Note that every call to getExcelStream needs to return an independent
> InputStream. For example, when you don\'t tell the result the
> contentLength it has no choice but to step through the entire stream to
> find the length, then it\'ll ask for a new stream to actually pull the
> data out of to send to the client.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment: user_182374.ezm (zipped)
bhaarat Sharma wrote:
>> What you need to do is provide the result with a source of the >data
> to be sent to the client.
>
> and that data has to be in java.io.InputStream??

An InputStream is a source of data.
An OutputStream is a destination for data.

> even if my getExcelStream method returns java.io.OutputStream...I
> still get an exception

Because the result can't read() from an OutputStream.

> so what TYPE of data should getExcelStream be returning :(

It should be returning something that extends InputStream.

I don't think your workbook method is doing what you think it's doing.
It might make sense if it took an output stream as a parameter, like
wb.write(outputStream), but if it is returning an output stream then
it's really asking for input...

-Dale

Attachment: user_182371.ezm (zipped)
We're using Struts 1.2.9 and the problem we're seeing is that if a user
tries to upload a file that does not exist or upload a file that exceeds
the maxFileSize attribute the FormFile object on the ActionForm is null
and so we cannot distinguish between the two.

We thought about removing the maxFileSize parameter and doing the check
ourselves in the ActionForm, but it appears that the file upload has
already begun at that point and while we can look at the Content-Length
header from the HttpServletRequest object in the Struts Action, it's a
moot step because the file has already begun to upload.

Is there a method on Action or DispatchAction (or perhaps something
else) that we can override to prevent the file upload if it exceeds a
size we determine? My concern is that Apache commons-fileupload gets
the request to upload the file first before Struts gets it and we might
be hozed in this regard.

Any thoughts? Thanks.

--adam

Attachment: user_182373.ezm (zipped)
Adam-

take a look at implementing FileUploadAction
http://jsourcery.com/api/apache/struts/2.0.6/org/apache/struts2/showcase/fil
eupload/FileUploadAction.html

M--
----- Original Message -----
From: "Adam Gordon" <adam.gordon@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Thursday, February 07, 2008 6:35 PM
Subject: File upload issues when maxFileSize is exceeded.


> We're using Struts 1.2.9 and the problem we're seeing is that if a user
> tries to upload a file that does not exist or upload a file that exceeds
> the maxFileSize attribute the FormFile object on the ActionForm is null
> and so we cannot distinguish between the two.
>
> We thought about removing the maxFileSize parameter and doing the check
> ourselves in the ActionForm, but it appears that the file upload has
> already begun at that point and while we can look at the Content-Length
> header from the HttpServletRequest object in the Struts Action, it's a
> moot step because the file has already begun to upload.
>
> Is there a method on Action or DispatchAction (or perhaps something
> else) that we can override to prevent the file upload if it exceeds a
> size we determine? My concern is that Apache commons-fileupload gets
> the request to upload the file first before Struts gets it and we might
> be hozed in this regard.
>
> Any thoughts? Thanks.
>
> --adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


Attachment: user_182375.ezm (zipped)
--- Martin Gainty <mgainty@(protected):
> take a look at implementing FileUploadAction
>
http://jsourcery.com/api/apache/struts/2.0.6/org/apache/struts2/showcase/fil
> eupload/FileUploadAction.html

"Adam Gordon" <adam.gordon@(protected):
> > We're using Struts 1.2.9

Dave


Attachment: user_182376.ezm (zipped)
I have a dynamic multi line collection of dates with a date converter doing its job perfectly - populating dates or reporting conversion errors by field as it should.

What I'm wondering is if it's possible to dynamically reference these fields without providing individually fixed definitions for each possible field.

For example, I can define each named field as follows:
<field name="account.userRoles[0].startDate">
<field-validator type="conversion">
  <param name="repopulateField">true</param>
  <message>${getText("errors.invalid.date")}</message>
</field-validator>
</field>

<field name="account.userRoles[1].startDate">
<field-validator type="conversion">
  <param name="repopulateField">true</param>
  <message>${getText("errors.invalid.date")}</message>
</field-validator>
</field>

etc.

This approach does work. However, I'd prefer have a single definition perhaps using a wildcard/regex since I don't know how many fields the user will submit.

Is it possible to substitute some kind of wildcard or regex here?

Thanks,
Grant




----Notice Regarding Confidentiality----
This email, including any and all attachments, (this "Email") is intended only for the party to whom it is addressed and may contain information that is confidential or privileged. Sierra Systems Group Inc. and its affiliates accept no responsibility for any loss or damage suffered by any person resulting from any unauthorized use of or reliance upon this Email. If you are not the intended recipient, you are hereby notified that any dissemination, copying or other use of this Email is prohibited. Please notify us of the error in communication by return email and destroy all copies of this Email. Thank you.

Attachment: user_182377.ezm (zipped)

Hi I'm using Struts 1.2.9,

what i want is,
if it's failed on validation then the error message display on the same
page, but if the validation success then I want the result display in new
window.

Question:
how can I trigger open new window using Struts (I don't want to open new
window using form target or windows open).


can anyone help me? thanks

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

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