You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon Wynacht <jo...@objectevolution.com> on 2007/05/28 17:13:37 UTC
Excel, Struts and Downloading
Hi,
I asked this question of the POI user mailing list but it's probably
a question for this list. If you don't know what POI is, check it out
here:
http://jakarta.apache.org/poi/
I used to run Struts 1.2.9, POI 2.5 and could generate Excel files
from a servlet and download them without issue. I recently upgraded
to Struts 1.3.5 and POI 3 and it looks like I broke that capability.
I'm getting the following error:
java.lang.IllegalStateException: getOutputStream() has already been
called for this response
I've searched through the Net and the archives here for info but
nothing really seems to fit for my situation; it's mostly JSP.
I'm calling an Action servlet which makes a call to the model and
gets some data, creates a new workbook and then does this:
<snip>
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition",
"attachment;filename=\"attendees.xls\"");
response.addHeader("Content-description", "Event
Attendees");
ServletOutputStream stream = response.getOutputStream
();
wb.write(stream);
stream.close();
...
forward = "SUCCESS";
...
return mapping.findForward(forward);
</snip>
It's what I did before I upgraded and things worked fine. Now they don't
Any ideas? Am I missing something really obvious or was I bending the
rules a bit and taking chances with my data in my previous config?
Cheers and thanks,
Jon
Jon Wynacht
jon@objectevolution.com
http://www.objectevolution.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by Mike Baroukh <mb...@cardiweb.com>.
>however I don't get the download anymore..
no idea why.
The only thing strange is
>>> wb.write(stream);
>>> stream.close();
I think you don't need close.
Instead, eventually, use flush() ...
What do you get when you write the stream to a file from the browser ? A
zero-length file ?
Maybe you can dump tcp traffic and see what is returned tio the browser
(tcpdump ? ethereal ?).
Mike
Jon Wynacht a écrit :
> Hi Mike,
>
> Yup. I did that and no error is thrown now, however I don't get the
> download anymore....I'm thinking I need to implement StrutsFileDownload
> instead and that's my link? Thoughts?
>
> Jon
>
> On May 28, 2007, at 8:21 AM, Mike Baroukh wrote:
>
>>
>> Hi.
>>
>> Maybe it has worked before, but I think you actually make an error :
>> If you already send a stream back to the client, it's not logic to
>> return "mapping.findForward()" because nothing else can be send to the
>> browser at this point.
>> You should simply return "null" ...
>>
>>
>> Mike
>>
>> Jon Wynacht a écrit :
>>> Hi,
>>> I asked this question of the POI user mailing list but it's probably
>>> a question for this list. If you don't know what POI is, check it out
>>> here:
>>> http://jakarta.apache.org/poi/
>>> I used to run Struts 1.2.9, POI 2.5 and could generate Excel files
>>> from a servlet and download them without issue. I recently upgraded
>>> to Struts 1.3.5 and POI 3 and it looks like I broke that capability.
>>> I'm getting the following error:
>>> java.lang.IllegalStateException: getOutputStream() has already been
>>> called for this response
>>> I've searched through the Net and the archives here for info but
>>> nothing really seems to fit for my situation; it's mostly JSP.
>>> I'm calling an Action servlet which makes a call to the model and
>>> gets some data, creates a new workbook and then does this:
>>> <snip>
>>> response.setContentType("application/vnd.ms-excel");
>>> response.setHeader("Content-disposition",
>>> "attachment;filename=\"attendees.xls\"");
>>> response.addHeader("Content-description", "Event
>>> Attendees");
>>> ServletOutputStream stream = response.getOutputStream();
>>> wb.write(stream);
>>> stream.close();
>>> ...
>>> forward = "SUCCESS";
>>> ...
>>> return mapping.findForward(forward);
>>> </snip>
>>> It's what I did before I upgraded and things worked fine. Now they don't
>>> Any ideas? Am I missing something really obvious or was I bending the
>>> rules a bit and taking chances with my data in my previous config?
>>> Cheers and thanks,
>>> Jon
>>> Jon Wynacht
>>> jon@objectevolution.com
>>> http://www.objectevolution.com
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>
>> --
>> Mike Baroukh
>>
>> ---
>> Cardiweb - 31 Rue de Mogador Paris IXeme
>> 06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
>> http://www.cardiweb.com
>> ---
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
> Jon Wynacht
> jon@objectevolution.com
> http://www.objectevolution.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Mike Baroukh
---
Cardiweb - 31 Rue de Mogador Paris IXeme
06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
http://www.cardiweb.com
---
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by Jon Wynacht <jo...@objectevolution.com>.
Thanks Frank. I was able to track down an issue with my SQL and have
resolved it.
I really appreciate this list...most of the time I lurk and glean
nuggets of goodness but on occasion when I've had some questions and
needed help...folks are there.
Cheers!
Jon
On May 28, 2007, at 11:00 AM, Frank W. Zammetti wrote:
> No, you don't need to implement StrutsFileDownload... What your
> doing should work fine... Can you throw together a quick, simple
> application that is nothing but a single Action that writes out
> "ok" to the response and returns null? See if that works... if
> what you describe is accurate, it sure sounds like something prior
> to your Action is getting the output stream, which probably should
> not be happening.
>
> Frank
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
> (2006, Apress, ISBN 1-59059-695-1)
> and "JavaScript, DOM Scripting and Ajax Projects"
> (2007, Apress, ISBN 1-59059-816-4)
> Java Web Parts - http://javawebparts.sourceforge.net
> Supplying the wheel, so you don't have to reinvent it!
>
> Jon Wynacht wrote:
>> Hi Mike,
>> Yup. I did that and no error is thrown now, however I don't get
>> the download anymore....I'm thinking I need to implement
>> StrutsFileDownload instead and that's my link? Thoughts?
>> Jon
>> On May 28, 2007, at 8:21 AM, Mike Baroukh wrote:
>>>
>>> Hi.
>>>
>>> Maybe it has worked before, but I think you actually make an
>>> error : If you already send a stream back to the client, it's not
>>> logic to return "mapping.findForward()" because nothing else can
>>> be send to the browser at this point.
>>> You should simply return "null" ...
>>>
>>>
>>> Mike
>>>
>>> Jon Wynacht a écrit :
>>>> Hi,
>>>> I asked this question of the POI user mailing list but it's
>>>> probably a question for this list. If you don't know what POI
>>>> is, check it out here:
>>>> http://jakarta.apache.org/poi/
>>>> I used to run Struts 1.2.9, POI 2.5 and could generate Excel
>>>> files from a servlet and download them without issue. I recently
>>>> upgraded to Struts 1.3.5 and POI 3 and it looks like I broke
>>>> that capability. I'm getting the following error:
>>>> java.lang.IllegalStateException: getOutputStream() has already
>>>> been called for this response
>>>> I've searched through the Net and the archives here for info but
>>>> nothing really seems to fit for my situation; it's mostly JSP.
>>>> I'm calling an Action servlet which makes a call to the model
>>>> and gets some data, creates a new workbook and then does this:
>>>> <snip>
>>>> response.setContentType("application/vnd.ms-excel");
>>>> response.setHeader("Content-disposition",
>>>> "attachment;filename=\"attendees.xls\"");
>>>> response.addHeader("Content-description", "Event
>>>> Attendees");
>>>> ServletOutputStream stream =
>>>> response.getOutputStream();
>>>> wb.write(stream);
>>>> stream.close();
>>>> ...
>>>> forward = "SUCCESS";
>>>> ...
>>>> return mapping.findForward(forward);
>>>> </snip>
>>>> It's what I did before I upgraded and things worked fine. Now
>>>> they don't
>>>> Any ideas? Am I missing something really obvious or was I
>>>> bending the rules a bit and taking chances with my data in my
>>>> previous config?
>>>> Cheers and thanks,
>>>> Jon
>>>> Jon Wynacht
>>>> jon@objectevolution.com
>>>> http://www.objectevolution.com
>>>> -------------------------------------------------------------------
>>>> --
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>> --
>>> Mike Baroukh
>>>
>>> ---
>>> Cardiweb - 31 Rue de Mogador Paris IXeme
>>> 06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
>>> http://www.cardiweb.com
>>> ---
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>> Jon Wynacht
>> jon@objectevolution.com
>> http://www.objectevolution.com
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> --No virus found in this incoming message.
>> Checked by AVG Free Edition.Version: 7.5.472 / Virus Database:
>> 269.8.0/821 - Release Date: 5/27/2007 3:05 PM
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
Jon Wynacht
jon@objectevolution.com
http://www.objectevolution.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Indresh Chadha wrote:
> I need to download a file from the server using AJAX & Struts.
> Is this possible?
No, it's not... well, assuming if by AJAX you mean using XMLHttpRequest,
but since AJAX is a technique, arguably using things like hidden frames
is still AJAX, and with that you could download a file certainly.
But, assuming you mean XMLHttpRequest, or some library that uses it
underneath, then no, you can't do this. The reason is that
XMLHttpRequest gives you a chunk of text, or an XML DOM object, but in
neither case can you write this to disk, or tell the browser to open it
with an appropriate handled application.
There are some nifty implementations out there using a hidden iFrame
that makes it *look* just like what you'd expect an AJAX-based download
to look like, but it's not, strictly speaking, a download via AJAX,
which isn't (currently) possible).
Frank
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
(2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
(2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!
> Frank W. Zammetti wrote:
>> No, you don't need to implement StrutsFileDownload... What your doing
>> should work fine... Can you throw together a quick, simple application
>> that is nothing but a single Action that writes out "ok" to the response
>> and returns null? See if that works... if what you describe is
>> accurate, it sure sounds like something prior to your Action is getting
>> the output stream, which probably should not be happening.
>>
>> Frank
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM/Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>> Author of "Practical Ajax Projects With Java Technology"
>> (2006, Apress, ISBN 1-59059-695-1)
>> and "JavaScript, DOM Scripting and Ajax Projects"
>> (2007, Apress, ISBN 1-59059-816-4)
>> Java Web Parts - http://javawebparts.sourceforge.net
>> Supplying the wheel, so you don't have to reinvent it!
>>
>> Jon Wynacht wrote:
>>> Hi Mike,
>>>
>>> Yup. I did that and no error is thrown now, however I don't get the
>>> download anymore....I'm thinking I need to implement StrutsFileDownload
>>> instead and that's my link? Thoughts?
>>>
>>> Jon
>>>
>>> On May 28, 2007, at 8:21 AM, Mike Baroukh wrote:
>>>
>>>> Hi.
>>>>
>>>> Maybe it has worked before, but I think you actually make an error :
>>>> If you already send a stream back to the client, it's not logic to
>>>> return "mapping.findForward()" because nothing else can be send to the
>>>> browser at this point.
>>>> You should simply return "null" ...
>>>>
>>>>
>>>> Mike
>>>>
>>>> Jon Wynacht a écrit :
>>>>> Hi,
>>>>> I asked this question of the POI user mailing list but it's probably
>>>>> a question for this list. If you don't know what POI is, check it out
>>>>> here:
>>>>> http://jakarta.apache.org/poi/
>>>>> I used to run Struts 1.2.9, POI 2.5 and could generate Excel files
>>>>> from a servlet and download them without issue. I recently upgraded
>>>>> to Struts 1.3.5 and POI 3 and it looks like I broke that capability.
>>>>> I'm getting the following error:
>>>>> java.lang.IllegalStateException: getOutputStream() has already been
>>>>> called for this response
>>>>> I've searched through the Net and the archives here for info but
>>>>> nothing really seems to fit for my situation; it's mostly JSP.
>>>>> I'm calling an Action servlet which makes a call to the model and
>>>>> gets some data, creates a new workbook and then does this:
>>>>> <snip>
>>>>> response.setContentType("application/vnd.ms-excel");
>>>>> response.setHeader("Content-disposition",
>>>>> "attachment;filename=\"attendees.xls\"");
>>>>> response.addHeader("Content-description", "Event
>>>>> Attendees");
>>>>> ServletOutputStream stream =
>>>>> response.getOutputStream();
>>>>> wb.write(stream);
>>>>> stream.close();
>>>>> ...
>>>>> forward = "SUCCESS";
>>>>> ...
>>>>> return mapping.findForward(forward);
>>>>> </snip>
>>>>> It's what I did before I upgraded and things worked fine. Now they
>>>>> don't
>>>>> Any ideas? Am I missing something really obvious or was I bending the
>>>>> rules a bit and taking chances with my data in my previous config?
>>>>> Cheers and thanks,
>>>>> Jon
>>>>> Jon Wynacht
>>>>> jon@objectevolution.com
>>>>> http://www.objectevolution.com
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>> --
>>>> Mike Baroukh
>>>>
>>>> ---
>>>> Cardiweb - 31 Rue de Mogador Paris IXeme
>>>> 06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
>>>> http://www.cardiweb.com
>>>> ---
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>> Jon Wynacht
>>> jon@objectevolution.com
>>> http://www.objectevolution.com
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>>
>>> --No virus found in this incoming message.
>>> Checked by AVG Free Edition.Version: 7.5.472 / Virus Database:
>>> 269.8.0/821 - Release Date: 5/27/2007 3:05 PM
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by Indresh Chadha <in...@hotmail.com>.
I need to download a file from the server using AJAX & Struts.
Is this possible?
Frank W. Zammetti wrote:
>
> No, you don't need to implement StrutsFileDownload... What your doing
> should work fine... Can you throw together a quick, simple application
> that is nothing but a single Action that writes out "ok" to the response
> and returns null? See if that works... if what you describe is
> accurate, it sure sounds like something prior to your Action is getting
> the output stream, which probably should not be happening.
>
> Frank
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Author of "Practical Ajax Projects With Java Technology"
> (2006, Apress, ISBN 1-59059-695-1)
> and "JavaScript, DOM Scripting and Ajax Projects"
> (2007, Apress, ISBN 1-59059-816-4)
> Java Web Parts - http://javawebparts.sourceforge.net
> Supplying the wheel, so you don't have to reinvent it!
>
> Jon Wynacht wrote:
>> Hi Mike,
>>
>> Yup. I did that and no error is thrown now, however I don't get the
>> download anymore....I'm thinking I need to implement StrutsFileDownload
>> instead and that's my link? Thoughts?
>>
>> Jon
>>
>> On May 28, 2007, at 8:21 AM, Mike Baroukh wrote:
>>
>>>
>>> Hi.
>>>
>>> Maybe it has worked before, but I think you actually make an error :
>>> If you already send a stream back to the client, it's not logic to
>>> return "mapping.findForward()" because nothing else can be send to the
>>> browser at this point.
>>> You should simply return "null" ...
>>>
>>>
>>> Mike
>>>
>>> Jon Wynacht a écrit :
>>>> Hi,
>>>> I asked this question of the POI user mailing list but it's probably
>>>> a question for this list. If you don't know what POI is, check it out
>>>> here:
>>>> http://jakarta.apache.org/poi/
>>>> I used to run Struts 1.2.9, POI 2.5 and could generate Excel files
>>>> from a servlet and download them without issue. I recently upgraded
>>>> to Struts 1.3.5 and POI 3 and it looks like I broke that capability.
>>>> I'm getting the following error:
>>>> java.lang.IllegalStateException: getOutputStream() has already been
>>>> called for this response
>>>> I've searched through the Net and the archives here for info but
>>>> nothing really seems to fit for my situation; it's mostly JSP.
>>>> I'm calling an Action servlet which makes a call to the model and
>>>> gets some data, creates a new workbook and then does this:
>>>> <snip>
>>>> response.setContentType("application/vnd.ms-excel");
>>>> response.setHeader("Content-disposition",
>>>> "attachment;filename=\"attendees.xls\"");
>>>> response.addHeader("Content-description", "Event
>>>> Attendees");
>>>> ServletOutputStream stream =
>>>> response.getOutputStream();
>>>> wb.write(stream);
>>>> stream.close();
>>>> ...
>>>> forward = "SUCCESS";
>>>> ...
>>>> return mapping.findForward(forward);
>>>> </snip>
>>>> It's what I did before I upgraded and things worked fine. Now they
>>>> don't
>>>> Any ideas? Am I missing something really obvious or was I bending the
>>>> rules a bit and taking chances with my data in my previous config?
>>>> Cheers and thanks,
>>>> Jon
>>>> Jon Wynacht
>>>> jon@objectevolution.com
>>>> http://www.objectevolution.com
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>> --
>>> Mike Baroukh
>>>
>>> ---
>>> Cardiweb - 31 Rue de Mogador Paris IXeme
>>> 06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
>>> http://www.cardiweb.com
>>> ---
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>
>> Jon Wynacht
>> jon@objectevolution.com
>> http://www.objectevolution.com
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>>
>> --No virus found in this incoming message.
>> Checked by AVG Free Edition.Version: 7.5.472 / Virus Database:
>> 269.8.0/821 - Release Date: 5/27/2007 3:05 PM
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Excel%2C-Struts-and-Downloading-tf3828502.html#a14169373
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: [s2] If Test Conditions
Posted by "Hoying, Ken" <Ke...@PremierInc.com>.
I will give that a try. I am sure it will work. Thank you so much for
your clear and detailed response. I now not only know what to do, but
more importantly why it needs to be done that way. Thank you!
-----Original Message-----
From: Jeromy Evans [mailto:jeromy.evans@blueskyminds.com.au]
Sent: Wednesday, May 30, 2007 10:10 AM
To: Struts Users Mailing List
Subject: Re: [s2] If Test Conditions
The problem is that displaytag places the current row in the pageContext
but none of your expressions are addressing it.
I tend to just use JSTL within displaytag tables as its much easier to
access the current row.
I also tend to add getters to my bean to simplify the expressions
instead of hardcoding it in the JSP. eg. isNew()
Anyway, this is a struts2 way to access it:
<display:table id="idContract" name="contracts" class="results">
<s:set name="rowIdContact" value="#attr.idContract"/>
<display:column titleKey="label.select">
<s:if test="#rowIdContact.equals('NEW')">
<s:checkbox name="selectedContracts"
etc.
The main point of that is that the idContact row is accessed via #attr
But this is my preferred way:
<display:table id="idContract" name="contracts" class="results">
<display:column titleKey="label.select">
<c:if test="idContract.new">
<s:checkbox name="selectedContracts"
where isNew() is property of the row class.
Hoying, Ken wrote:
> I am having a devil of a time getting a simple if test condition to
> work properly.
>
> Here is the jist of what I am trying to do:
>
> <display:table id="idContract" name="contracts" class="results">
> <display:column titleKey="label.select">
> <s:if test="${idContract.status}=='NEW'">
> <s:checkbox name="selectedContracts"
> fieldValue="${idContract.id}"/>
> </s:if>
> <s:else>
> ${idContract.status}
> </s:else>
> </display:column>
> <display:column property="number"
> titleKey="label.contractNumber" />
> <display:column property="status"
> titleKey="label.contractStatus" />
> <display:column property="numAuthFacilities"
> titleKey="label.authFacilities" />
> </display:table>
>
> I have tried the following and do not seem to be able to get any of
> them to work:
> "${idContract.status}=='NEW'"
> '${idContract.status}=="NEW"'
> "%{idContract.status}=='NEW'"
> "${idContract.status=='NEW'}"
> "%{idContract.status=='NEW'}"
> "idContract.status=='NEW'"
> "#idContract.status=='NEW'"
>
> And a host of others that I cannot recall.
>
> Does anyone happen to know the correct syntax? I am getting tired of
> guessing and cannot seem to make rhyme or reason out of the syntax
> rules
> :-)
>
> Thanks in advance!
>
> -----------------------------------------
> ***Note:The information contained in this message may be privileged
> and confidential and protected from disclosure. If the reader of this
> message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you
> are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please notify the Sender immediately by
> replying to the message and deleting it from your computer. Thank you.
> Premier Inc.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [s2] If Test Conditions
Posted by Dave Newton <ne...@yahoo.com>.
--- Jeromy Evans wrote:
> The problem is that displaytag places the current
> row in the pageContext but none of your expressions
> are addressing it.
Or it could be that ;)
Dave "Shouldn't answer questions about taglibs he
doesn't know" Newton
____________________________________________________________________________________Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [s2] If Test Conditions
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
The problem is that displaytag places the current row in the pageContext
but none of your expressions are addressing it.
I tend to just use JSTL within displaytag tables as its much easier to
access the current row.
I also tend to add getters to my bean to simplify the expressions
instead of hardcoding it in the JSP. eg. isNew()
Anyway, this is a struts2 way to access it:
<display:table id="idContract" name="contracts" class="results">
<s:set name="rowIdContact" value="#attr.idContract"/>
<display:column titleKey="label.select">
<s:if test="#rowIdContact.equals('NEW')">
<s:checkbox name="selectedContracts"
etc.
The main point of that is that the idContact row is accessed via #attr
But this is my preferred way:
<display:table id="idContract" name="contracts" class="results">
<display:column titleKey="label.select">
<c:if test="idContract.new">
<s:checkbox name="selectedContracts"
where isNew() is property of the row class.
Hoying, Ken wrote:
> I am having a devil of a time getting a simple if test condition to work
> properly.
>
> Here is the jist of what I am trying to do:
>
> <display:table id="idContract" name="contracts" class="results">
> <display:column titleKey="label.select">
> <s:if test="${idContract.status}=='NEW'">
> <s:checkbox name="selectedContracts"
> fieldValue="${idContract.id}"/>
> </s:if>
> <s:else>
> ${idContract.status}
> </s:else>
> </display:column>
> <display:column property="number"
> titleKey="label.contractNumber" />
> <display:column property="status"
> titleKey="label.contractStatus" />
> <display:column property="numAuthFacilities"
> titleKey="label.authFacilities" />
> </display:table>
>
> I have tried the following and do not seem to be able to get any of them
> to work:
> "${idContract.status}=='NEW'"
> '${idContract.status}=="NEW"'
> "%{idContract.status}=='NEW'"
> "${idContract.status=='NEW'}"
> "%{idContract.status=='NEW'}"
> "idContract.status=='NEW'"
> "#idContract.status=='NEW'"
>
> And a host of others that I cannot recall.
>
> Does anyone happen to know the correct syntax? I am getting tired of
> guessing and cannot seem to make rhyme or reason out of the syntax rules
> :-)
>
> Thanks in advance!
>
> -----------------------------------------
> ***Note:The information contained in this message may be privileged
> and confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient,
> you are hereby notified that any dissemination, distribution or
> copying of this communication is strictly prohibited. If you have
> received this communication in error, please notify the Sender
> immediately by replying to the message and deleting it from your
> computer. Thank you. Premier Inc.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [s2] If Test Conditions
Posted by Dave Newton <ne...@yahoo.com>.
--- "Hoying, Ken" <Ke...@PremierInc.com> wrote:
> "${idContract.status}=='NEW'"
> '${idContract.status}=="NEW"'
> "%{idContract.status}=='NEW'"
These close the OGNL expression too early.
> "${idContract.status=='NEW'}"
> "%{idContract.status=='NEW'}"
> "idContract.status=='NEW'"
> "#idContract.status=='NEW'"
As long as your action exposes 'idContract'
JavaBean-ily and the contract does the same for
'status' then
test="%{idContract.status == 'NEW'}"
should work (and you may not need the %{} bits; I
don't recall for this tag attribute).
d.
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
[s2] If Test Conditions
Posted by "Hoying, Ken" <Ke...@PremierInc.com>.
I am having a devil of a time getting a simple if test condition to work
properly.
Here is the jist of what I am trying to do:
<display:table id="idContract" name="contracts" class="results">
<display:column titleKey="label.select">
<s:if test="${idContract.status}=='NEW'">
<s:checkbox name="selectedContracts"
fieldValue="${idContract.id}"/>
</s:if>
<s:else>
${idContract.status}
</s:else>
</display:column>
<display:column property="number"
titleKey="label.contractNumber" />
<display:column property="status"
titleKey="label.contractStatus" />
<display:column property="numAuthFacilities"
titleKey="label.authFacilities" />
</display:table>
I have tried the following and do not seem to be able to get any of them
to work:
"${idContract.status}=='NEW'"
'${idContract.status}=="NEW"'
"%{idContract.status}=='NEW'"
"${idContract.status=='NEW'}"
"%{idContract.status=='NEW'}"
"idContract.status=='NEW'"
"#idContract.status=='NEW'"
And a host of others that I cannot recall.
Does anyone happen to know the correct syntax? I am getting tired of
guessing and cannot seem to make rhyme or reason out of the syntax rules
:-)
Thanks in advance!
-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer. Thank you. Premier Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
No, you don't need to implement StrutsFileDownload... What your doing
should work fine... Can you throw together a quick, simple application
that is nothing but a single Action that writes out "ok" to the response
and returns null? See if that works... if what you describe is
accurate, it sure sounds like something prior to your Action is getting
the output stream, which probably should not be happening.
Frank
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
(2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
(2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!
Jon Wynacht wrote:
> Hi Mike,
>
> Yup. I did that and no error is thrown now, however I don't get the
> download anymore....I'm thinking I need to implement StrutsFileDownload
> instead and that's my link? Thoughts?
>
> Jon
>
> On May 28, 2007, at 8:21 AM, Mike Baroukh wrote:
>
>>
>> Hi.
>>
>> Maybe it has worked before, but I think you actually make an error :
>> If you already send a stream back to the client, it's not logic to
>> return "mapping.findForward()" because nothing else can be send to the
>> browser at this point.
>> You should simply return "null" ...
>>
>>
>> Mike
>>
>> Jon Wynacht a écrit :
>>> Hi,
>>> I asked this question of the POI user mailing list but it's probably
>>> a question for this list. If you don't know what POI is, check it out
>>> here:
>>> http://jakarta.apache.org/poi/
>>> I used to run Struts 1.2.9, POI 2.5 and could generate Excel files
>>> from a servlet and download them without issue. I recently upgraded
>>> to Struts 1.3.5 and POI 3 and it looks like I broke that capability.
>>> I'm getting the following error:
>>> java.lang.IllegalStateException: getOutputStream() has already been
>>> called for this response
>>> I've searched through the Net and the archives here for info but
>>> nothing really seems to fit for my situation; it's mostly JSP.
>>> I'm calling an Action servlet which makes a call to the model and
>>> gets some data, creates a new workbook and then does this:
>>> <snip>
>>> response.setContentType("application/vnd.ms-excel");
>>> response.setHeader("Content-disposition",
>>> "attachment;filename=\"attendees.xls\"");
>>> response.addHeader("Content-description", "Event
>>> Attendees");
>>> ServletOutputStream stream = response.getOutputStream();
>>> wb.write(stream);
>>> stream.close();
>>> ...
>>> forward = "SUCCESS";
>>> ...
>>> return mapping.findForward(forward);
>>> </snip>
>>> It's what I did before I upgraded and things worked fine. Now they don't
>>> Any ideas? Am I missing something really obvious or was I bending the
>>> rules a bit and taking chances with my data in my previous config?
>>> Cheers and thanks,
>>> Jon
>>> Jon Wynacht
>>> jon@objectevolution.com
>>> http://www.objectevolution.com
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>
>> --
>> Mike Baroukh
>>
>> ---
>> Cardiweb - 31 Rue de Mogador Paris IXeme
>> 06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
>> http://www.cardiweb.com
>> ---
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
> Jon Wynacht
> jon@objectevolution.com
> http://www.objectevolution.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
> --No virus found in this incoming message.
> Checked by AVG Free Edition.Version: 7.5.472 / Virus Database:
> 269.8.0/821 - Release Date: 5/27/2007 3:05 PM
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by Jon Wynacht <jo...@objectevolution.com>.
Hi Mike,
Yup. I did that and no error is thrown now, however I don't get the
download anymore....I'm thinking I need to implement
StrutsFileDownload instead and that's my link? Thoughts?
Jon
On May 28, 2007, at 8:21 AM, Mike Baroukh wrote:
>
> Hi.
>
> Maybe it has worked before, but I think you actually make an
> error : If you already send a stream back to the client, it's not
> logic to return "mapping.findForward()" because nothing else can be
> send to the browser at this point.
> You should simply return "null" ...
>
>
> Mike
>
> Jon Wynacht a écrit :
>> Hi,
>> I asked this question of the POI user mailing list but it's
>> probably a question for this list. If you don't know what POI is,
>> check it out here:
>> http://jakarta.apache.org/poi/
>> I used to run Struts 1.2.9, POI 2.5 and could generate Excel files
>> from a servlet and download them without issue. I recently
>> upgraded to Struts 1.3.5 and POI 3 and it looks like I broke that
>> capability. I'm getting the following error:
>> java.lang.IllegalStateException: getOutputStream() has already
>> been called for this response
>> I've searched through the Net and the archives here for info but
>> nothing really seems to fit for my situation; it's mostly JSP.
>> I'm calling an Action servlet which makes a call to the model and
>> gets some data, creates a new workbook and then does this:
>> <snip>
>> response.setContentType("application/vnd.ms-excel");
>> response.setHeader("Content-disposition",
>> "attachment;filename=\"attendees.xls\"");
>> response.addHeader("Content-description", "Event
>> Attendees");
>> ServletOutputStream stream =
>> response.getOutputStream();
>> wb.write(stream);
>> stream.close();
>> ...
>> forward = "SUCCESS";
>> ...
>> return mapping.findForward(forward);
>> </snip>
>> It's what I did before I upgraded and things worked fine. Now they
>> don't
>> Any ideas? Am I missing something really obvious or was I bending
>> the rules a bit and taking chances with my data in my previous
>> config?
>> Cheers and thanks,
>> Jon
>> Jon Wynacht
>> jon@objectevolution.com
>> http://www.objectevolution.com
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
> --
>
> Mike Baroukh
>
> ---
> Cardiweb - 31 Rue de Mogador Paris IXeme
> 06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
> http://www.cardiweb.com
> ---
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
Jon Wynacht
jon@objectevolution.com
http://www.objectevolution.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Excel, Struts and Downloading
Posted by Mike Baroukh <mb...@cardiweb.com>.
Hi.
Maybe it has worked before, but I think you actually make an error : If
you already send a stream back to the client, it's not logic to return
"mapping.findForward()" because nothing else can be send to the browser
at this point.
You should simply return "null" ...
Mike
Jon Wynacht a écrit :
> Hi,
>
> I asked this question of the POI user mailing list but it's probably a
> question for this list. If you don't know what POI is, check it out here:
>
> http://jakarta.apache.org/poi/
>
> I used to run Struts 1.2.9, POI 2.5 and could generate Excel files from
> a servlet and download them without issue. I recently upgraded to Struts
> 1.3.5 and POI 3 and it looks like I broke that capability. I'm getting
> the following error:
>
> java.lang.IllegalStateException: getOutputStream() has already been
> called for this response
>
> I've searched through the Net and the archives here for info but nothing
> really seems to fit for my situation; it's mostly JSP.
>
> I'm calling an Action servlet which makes a call to the model and gets
> some data, creates a new workbook and then does this:
>
> <snip>
> response.setContentType("application/vnd.ms-excel");
> response.setHeader("Content-disposition",
> "attachment;filename=\"attendees.xls\"");
> response.addHeader("Content-description", "Event
> Attendees");
> ServletOutputStream stream = response.getOutputStream();
> wb.write(stream);
> stream.close();
> ...
> forward = "SUCCESS";
> ...
> return mapping.findForward(forward);
> </snip>
>
> It's what I did before I upgraded and things worked fine. Now they don't
>
> Any ideas? Am I missing something really obvious or was I bending the
> rules a bit and taking chances with my data in my previous config?
>
> Cheers and thanks,
>
> Jon
>
> Jon Wynacht
> jon@objectevolution.com
> http://www.objectevolution.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Mike Baroukh
---
Cardiweb - 31 Rue de Mogador Paris IXeme
06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
http://www.cardiweb.com
---
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org