You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nick J <ni...@gmail.com> on 2008/11/01 22:54:57 UTC

Struts2 upload

Hi, I am having some trouble with Uploads in Struts 2.
Here is the action:
<package name="uploads" extends="json-default" namespace="/_uploads">
<!-- ...other actions ...-->
		<action name="imageUpload" class="uploadManager" method="imageUpload">
			<interceptor-ref name="fileUpload"/>
			<result>/upload.html</result>
		</action>
</package>

Here is the HTML form:
<form name="myForm" action="/_uploads/imageUpload"
enctype="multipart/form-data">
     <input type="file" name="imageUpload" value="Browse ..." />
     <input type="submit" />
</form>

Here's the appropriate part of the action class:

	public String imageUpload() {
		return ActionSupport.SUCCESS;
	}
	
	public List<Image> getImageList() {
		return images;
	}
	
	public void setImageUpload(File myImage) {
		uploadedImage = myImage;
	}
	
	public void setImageUploadContentType(String contentType) {
		imageContentType = contentType;
	}
	
	public void setImageUploadFileName(String filename) {
		imageFilename = filename;
	}

I have debugger break-points in the  imageUpload method, and in the setter
methods. 
The execution never reaches the setters, and when it breaks in the
imageUpload method,
and I inspect the values of uploadedImage, imageContentType and
imageFilename they are all null, so the interceptor has not called the the
setters like I was expecting it to. As far as I can tell, this agrees with
all the tutorials I've read, so I'm at a loss now. If anyone has any ideas,
I'd be very greatful!

thanks!



-- 
View this message in context: http://www.nabble.com/Struts2-upload-tp20284756p20284756.html
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: Struts2 upload

Posted by Mead Lai <la...@gmail.com>.
<package name="uploads" extends="json-default"

Why not ' extends="struts-default" '?
the form, you need set the "method=post",<s:form method='post'>

On Sun, Nov 2, 2008 at 6:02 AM, Wes Wannemacher <we...@wantii.com> wrote:

> what is in the fileUpload interceptor stack? Since the setter is never
> called, I would wonder if it is a complete stack.
>
> When you use <interceptor-ref> in an action definition, you are
> overwriting the existing stack with the stack you specify.
>
> -Wes
>
>
> On Sat, 2008-11-01 at 14:54 -0700, Nick J wrote:
> > Hi, I am having some trouble with Uploads in Struts 2.
> > Here is the action:
> > <package name="uploads" extends="json-default" namespace="/_uploads">
> > <!-- ...other actions ...-->
> >               <action name="imageUpload" class="uploadManager"
> method="imageUpload">
> >                       <interceptor-ref name="fileUpload"/>
> >                       <result>/upload.html</result>
> >               </action>
> > </package>
> >
> > Here is the HTML form:
> > <form name="myForm" action="/_uploads/imageUpload"
> > enctype="multipart/form-data">
> >      <input type="file" name="imageUpload" value="Browse ..." />
> >      <input type="submit" />
> > </form>
> >
> > Here's the appropriate part of the action class:
> >
> >       public String imageUpload() {
> >               return ActionSupport.SUCCESS;
> >       }
> >
> >       public List<Image> getImageList() {
> >               return images;
> >       }
> >
> >       public void setImageUpload(File myImage) {
> >               uploadedImage = myImage;
> >       }
> >
> >       public void setImageUploadContentType(String contentType) {
> >               imageContentType = contentType;
> >       }
> >
> >       public void setImageUploadFileName(String filename) {
> >               imageFilename = filename;
> >       }
> >
> > I have debugger break-points in the  imageUpload method, and in the
> setter
> > methods.
> > The execution never reaches the setters, and when it breaks in the
> > imageUpload method,
> > and I inspect the values of uploadedImage, imageContentType and
> > imageFilename they are all null, so the interceptor has not called the
> the
> > setters like I was expecting it to. As far as I can tell, this agrees
> with
> > all the tutorials I've read, so I'm at a loss now. If anyone has any
> ideas,
> > I'd be very greatful!
> >
> > thanks!
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
BestRegards,
Mead
http://yayisoft.com

Bernard Baruch  - "Vote for the man who promises least; he'll be the least
disappointing."

Re: Struts2 upload

Posted by Wes Wannemacher <we...@wantii.com>.
what is in the fileUpload interceptor stack? Since the setter is never
called, I would wonder if it is a complete stack.

When you use <interceptor-ref> in an action definition, you are
overwriting the existing stack with the stack you specify.

-Wes


On Sat, 2008-11-01 at 14:54 -0700, Nick J wrote:
> Hi, I am having some trouble with Uploads in Struts 2.
> Here is the action:
> <package name="uploads" extends="json-default" namespace="/_uploads">
> <!-- ...other actions ...-->
> 		<action name="imageUpload" class="uploadManager" method="imageUpload">
> 			<interceptor-ref name="fileUpload"/>
> 			<result>/upload.html</result>
> 		</action>
> </package>
> 
> Here is the HTML form:
> <form name="myForm" action="/_uploads/imageUpload"
> enctype="multipart/form-data">
>      <input type="file" name="imageUpload" value="Browse ..." />
>      <input type="submit" />
> </form>
> 
> Here's the appropriate part of the action class:
> 
> 	public String imageUpload() {
> 		return ActionSupport.SUCCESS;
> 	}
> 	
> 	public List<Image> getImageList() {
> 		return images;
> 	}
> 	
> 	public void setImageUpload(File myImage) {
> 		uploadedImage = myImage;
> 	}
> 	
> 	public void setImageUploadContentType(String contentType) {
> 		imageContentType = contentType;
> 	}
> 	
> 	public void setImageUploadFileName(String filename) {
> 		imageFilename = filename;
> 	}
> 
> I have debugger break-points in the  imageUpload method, and in the setter
> methods. 
> The execution never reaches the setters, and when it breaks in the
> imageUpload method,
> and I inspect the values of uploadedImage, imageContentType and
> imageFilename they are all null, so the interceptor has not called the the
> setters like I was expecting it to. As far as I can tell, this agrees with
> all the tutorials I've read, so I'm at a loss now. If anyone has any ideas,
> I'd be very greatful!
> 
> thanks!
> 
> 
> 


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


Second box of DoubleSeclect tag wont show the default value even though it's right here.

Posted by Jipu Jiang <j....@nesc.gla.ac.uk>.
Hello everyone,

Can anyone help me to solve this issue with doubleselect box of struts2?

I would like to display some database data on a page by using some struts2
tags. So we should go to the action class fist to fetch the data, then
dispatch the request to the jsp page when success. Everything shows up real
nice except the second list of the doubleselet tag. For example, I have a
list with all the countries, each of which contains a list of cities. E.g.
UK contains London, Manchester, Liverpool, Glasgow, etc (assume in such
order). So the doubleselect box will display countries as the first select
box, and related cities will display in the second select box. Then if the
Action class got UK and Liverpool, the doubleselect tag should display both
of them. But instead, the doubleselect tag shows UK as the first box, and
London as the second. When selecting other countries, same thing happens.
And it is always the first option in the second list to be displayed.

I have double checked the getter and setters for the double select list,
they are all good. And the jsp page can get these values. If anyone want to
see the code, please see the previous message below.

I have been struggling with this problem for many days. Could anyone point
me a path to solve this problem? It will be greatly appreciated.

Many thanks in advance,
Jipu 


On 11/11/2008 01:34, "Jipu Jiang" <j....@nesc.gla.ac.uk> wrote:

> Hi Felippe,
> 
> Thank you for your fast reply. I have double checked with what you have
> suggested. But the problem is still here.
> 
> Regarding to the situation, the second list contains all the options
> actually. If I show only the doubleselect box without default values to
> show, all the options are there. And if I change the selection of fist
> select box, the second one will change accordingly. This means the
> doubleselect box is up and running well.
> 
> But the problem is I have default values to show when user see the
> doubleselect box, and the default value for second list was not shown
> correctly (some option is selected, but not the right one).
> 
> For example, the first list contains countries, and second list contains
> associated cities. E.g. UK list contains Edinburgh, Oxford, London,
> etc.(in such order), and if the database stores a record with
> country=UK, and City=London, the doubleselect list should display the
> fist list as UK, and second list as London. But the problem is the first
> list can show UK, while the second list show only the first one in the
> tertiaryoptions list. As in this example, it shows Edinburgh - the fist
> element of the second list. And it supposes to show London - the third
> one of second list..
> 
> In this implementation, I have the action class contains identifier
> variable, and associated getters and setters. In the JSP, I set the name
> of doubleselect tag to be "%{'identifier.' + paramName}", so when the
> page renders, the value in identifier variable can be shown directly on
> the page. I have tested this with textfield, checkbox, select, etc. they
> all worked fine to show default values, except the doubleselect tag.
> 
> I wonder is anything wrong with my implementation, or doubleselect list
> just don't have such ability?
> 
> Another guess I had is the Javascript used in doubleselect tag. The
> second select list is actually generated by javascript. This might be
> the reason to cause above issues. May be I've been paranoid?
> 
> Anyway, I have been stuck with this issue for a long time now. Still
> cant figure out why. Your help would be very much appreciated.
> 
> Thanks again Felippe,
> 
> Cheers,
> Jipu
> 
> -----Original Message-----
> From: Felippe Scheidt [mailto:felippescheidt@gmail.com]
> Sent: Monday, November 10, 2008 8:17 PM
> To: Struts Users Mailing List
> Subject: Re: HELP!!! DoubleSeclect tag with default values
> 
> Hi Jipu,
> 
> Well, if i understood correctly, the second list, "tertiaryoptions" is
> been
> completed with only one city, and there is another cities of course. The
> doubleselect tag bind the two lists behind through ValueStack. For this
> works correctly, verify the first list, "menu.menuoptions". This is
> probably
> a list of MenuOption. Verify if MenuOption contains a list of
> tertiaryoptions, something like this:
> public class Menuoption{
> ...
>   List<TertiaryOption> tertiaryoptions;
> ...
> }
> 
> This is a way to doubleselect binds this two collections.
> 
> Felippe.
> 
> 
> 
> On Mon, Nov 10, 2008 at 2:33 PM, Jipu Jiang <j....@nesc.gla.ac.uk>
> wrote:
> 
>> Hi Felippe,
>> 
>> Thank you so much for the response. Sure, here is the code:
>> 
>> JSP:
>> 
>> <s:form id="editRecordForm" action="updateRecord" theme="simple">
>>        <table class="query-page-table">
>>                <tr>
>>                        <s:iterator value="sections" id="sec"
>> status="secs">
>>                                <table class="section-table">
>>                                        <tr>
>>                                                <td colspan="3">
>>                                                        <h3>
>> 
>> <s:property value="name" />
>>                                                        </h3>
>>                                                </td>
>>                                        </tr>
>> 
>>                                        <s:iterator value="parameters"
>> id="para" status="paras">
>>                                                <tr>
>>                                                        <td
>> class="parameter-label">
>> 
>> <s:property value="label" />
>>                                                        </td>
>>                                                        <td>
>>                                                                <s:if
>> test="type == \"menu\"">
>> 
>> <s:set name="menuoptions" value="menu.menuoptions"></s:set>
>> 
>> <s:set name="tertiaryParamName"
> value="menu.tertiaryParamName"></s:set>
>> 
>> <s:if test="menu.tertiary == 1">
>> 
>> <s:doubleselect name="%{'identifier.' + paramName}"
>> 
>> headerKey="" headerValue="--- Please Select ---"
>> 
>> list="menu.menuoptions" listKey="value" listValue="value"
>> 
>> doubleId="%{'editRecordForm_identifier_' + menu.tertiaryParamName}"
>> 
>> doubleName="%{'identifier.' + menu.tertiaryParamName}"
>> 
>> doubleList="tertiaryoptions" doubleListKey="name"
>> 
>> doubleListValue="name" />
>> 
>> </s:if>
>> 
>> <s:else>
>> 
>> <s:select name="%{'identifier.' + paramName}"
>> 
>> listKey="value" label="%{para.label}" list="menu.menuoptions"
>> 
>> listValue="value" emptyOption="false" headerKey=""
>> 
>> headerValue="--- Please Select ---" theme="simple" />
>> 
>> </s:else>
>>                                                                </s:if>
>>                                                        </td>
>>                                                </tr>
>> 
>>                                        </s:iterator>
>>                                </table>
>>                        </s:iterator>
>>                </tr>
>>                <tr>
>>                        <td colspan="3" align="right">
>>                                <br />
>>                                <s:submit value="Update Record"
>> theme="simple"></s:submit>
>>                                <s:reset theme="simple"></s:reset>
>>                        </td>
>>                </tr>
>>        </table>
>> 
>> </s:form>
>> 
>> 
> ------------------------------------------------------------------------
>> Here is the updateRecordView Method in the UpdateRecordAction.java:
>> 
>>        public String updateRecordView() throws Exception {
>>                try {
>>                        this.sections =
>> this.parameterManager.getSections();
>>                        this.identifier =
>> this.identifierManager.getIdentifierByRegisterId(this.id);
>>                        return SUCCESS;
>>                } catch (CannotCreateTransactionException e) {
>>                        log.error("CannotCreateTransactionException:
>> Hibernate transaction exception!!! Timeout.");
>>                        e.printStackTrace();
>>                        return EXPIRE;
>>                } catch (Exception e) {
>>                        log.error("Exception caught in
>> readRecordView()!!!");
>>                        return ERROR;
>>                }
>>        }
>> 
>> 
>> User access goes to updateRecordView action first, and fetch data from
>> database. If successful, it goes to the jsp page to show the
> parameters
>> and associated values. But the doubleselect tag shows only the value
> of
>> fist select box, second box shows the first option in from the list,
> not
>> the one suppose to display.
>> 
>> Any help would be much appreciated.
>> 
>> Many thanks,
>> Jipu
>> 
>> -----Original Message-----
>> From: Felippe Scheidt [mailto:felippescheidt@gmail.com]
>> Sent: Monday, November 10, 2008 12:22 PM
>> To: Struts Users Mailing List
>> Subject: Re: HELP!!! DoubleSeclect tag with default values
>> 
>> Can you paste your code please?
>> 
>> Scheidt.
>> 
>> 
>> On Mon, Nov 10, 2008 at 9:04 AM, Jipu Jiang <j....@nesc.gla.ac.uk>
>> wrote:
>> 
>>> Dear all,
>>> 
>>> I was trying to display a JSP page with some parameters from the
>>> database. Everything shows up perfectly except the second dropdown
>> list
>>> of the doubleselect tag, which should display the value from java
>> action
>>> but it always shows the first value of the second list.
>>> 
>>> For example, the first list contains countries and the second list
>>> contains cities. E.g. if I select UK from the first select box, the
>>> second should be London, Birmingham, Edinburgh etc.
>>> 
>>> Now the default values of the select boxes depend on what's in the
>>> database. I can get the first select box to show UK, but the second
>> one
>>> always shows London, which is the first one in the second list.
>> Instead,
>>> it should show other cities based on values in database.
>>> 
>>> I guess it's because of javascript. Does anyone know how to deal
> with
>>> such problem?
>>> 
>>> Also, when I assign values to the doubleHeaderKey and
>> doubleHeaderValue
>>> of doubleselect tag, the second select box shows no header at all.
> How
>>> can I make this work?
>>> 
>>> Many thanks in advance,
>>> Jipu
>>> 
>>> 
> ---------------------------------------------------------------------
>>> 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
> 


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


RE: HELP!!! Struts2 bugs? DoubleSeclect tag with default values

Posted by Jipu Jiang <j....@nesc.gla.ac.uk>.
Hi Felippe,

Thank you for your fast reply. I have double checked with what you have
suggested. But the problem is still here. 

Regarding to the situation, the second list contains all the options
actually. If I show only the doubleselect box without default values to
show, all the options are there. And if I change the selection of fist
select box, the second one will change accordingly. This means the
doubleselect box is up and running well.

But the problem is I have default values to show when user see the
doubleselect box, and the default value for second list was not shown
correctly (some option is selected, but not the right one). 

For example, the first list contains countries, and second list contains
associated cities. E.g. UK list contains Edinburgh, Oxford, London,
etc.(in such order), and if the database stores a record with
country=UK, and City=London, the doubleselect list should display the
fist list as UK, and second list as London. But the problem is the first
list can show UK, while the second list show only the first one in the
tertiaryoptions list. As in this example, it shows Edinburgh - the fist
element of the second list. And it supposes to show London - the third
one of second list.. 

In this implementation, I have the action class contains identifier
variable, and associated getters and setters. In the JSP, I set the name
of doubleselect tag to be "%{'identifier.' + paramName}", so when the
page renders, the value in identifier variable can be shown directly on
the page. I have tested this with textfield, checkbox, select, etc. they
all worked fine to show default values, except the doubleselect tag. 

I wonder is anything wrong with my implementation, or doubleselect list
just don't have such ability? 

Another guess I had is the Javascript used in doubleselect tag. The
second select list is actually generated by javascript. This might be
the reason to cause above issues. May be I've been paranoid?

Anyway, I have been stuck with this issue for a long time now. Still
cant figure out why. Your help would be very much appreciated.

Thanks again Felippe,

Cheers,
Jipu

-----Original Message-----
From: Felippe Scheidt [mailto:felippescheidt@gmail.com] 
Sent: Monday, November 10, 2008 8:17 PM
To: Struts Users Mailing List
Subject: Re: HELP!!! DoubleSeclect tag with default values

Hi Jipu,

Well, if i understood correctly, the second list, "tertiaryoptions" is
been
completed with only one city, and there is another cities of course. The
doubleselect tag bind the two lists behind through ValueStack. For this
works correctly, verify the first list, "menu.menuoptions". This is
probably
a list of MenuOption. Verify if MenuOption contains a list of
tertiaryoptions, something like this:
public class Menuoption{
...
  List<TertiaryOption> tertiaryoptions;
...
}

This is a way to doubleselect binds this two collections.

Felippe.



On Mon, Nov 10, 2008 at 2:33 PM, Jipu Jiang <j....@nesc.gla.ac.uk>
wrote:

> Hi Felippe,
>
> Thank you so much for the response. Sure, here is the code:
>
> JSP:
>
> <s:form id="editRecordForm" action="updateRecord" theme="simple">
>        <table class="query-page-table">
>                <tr>
>                        <s:iterator value="sections" id="sec"
> status="secs">
>                                <table class="section-table">
>                                        <tr>
>                                                <td colspan="3">
>                                                        <h3>
>
> <s:property value="name" />
>                                                        </h3>
>                                                </td>
>                                        </tr>
>
>                                        <s:iterator value="parameters"
> id="para" status="paras">
>                                                <tr>
>                                                        <td
> class="parameter-label">
>
> <s:property value="label" />
>                                                        </td>
>                                                        <td>
>                                                                <s:if
> test="type == \"menu\"">
>
> <s:set name="menuoptions" value="menu.menuoptions"></s:set>
>
> <s:set name="tertiaryParamName"
value="menu.tertiaryParamName"></s:set>
>
> <s:if test="menu.tertiary == 1">
>
> <s:doubleselect name="%{'identifier.' + paramName}"
>
> headerKey="" headerValue="--- Please Select ---"
>
> list="menu.menuoptions" listKey="value" listValue="value"
>
> doubleId="%{'editRecordForm_identifier_' + menu.tertiaryParamName}"
>
> doubleName="%{'identifier.' + menu.tertiaryParamName}"
>
> doubleList="tertiaryoptions" doubleListKey="name"
>
> doubleListValue="name" />
>
> </s:if>
>
> <s:else>
>
> <s:select name="%{'identifier.' + paramName}"
>
> listKey="value" label="%{para.label}" list="menu.menuoptions"
>
> listValue="value" emptyOption="false" headerKey=""
>
> headerValue="--- Please Select ---" theme="simple" />
>
> </s:else>
>                                                                </s:if>
>                                                        </td>
>                                                </tr>
>
>                                        </s:iterator>
>                                </table>
>                        </s:iterator>
>                </tr>
>                <tr>
>                        <td colspan="3" align="right">
>                                <br />
>                                <s:submit value="Update Record"
> theme="simple"></s:submit>
>                                <s:reset theme="simple"></s:reset>
>                        </td>
>                </tr>
>        </table>
>
> </s:form>
>
>
------------------------------------------------------------------------
> Here is the updateRecordView Method in the UpdateRecordAction.java:
>
>        public String updateRecordView() throws Exception {
>                try {
>                        this.sections =
> this.parameterManager.getSections();
>                        this.identifier =
> this.identifierManager.getIdentifierByRegisterId(this.id);
>                        return SUCCESS;
>                } catch (CannotCreateTransactionException e) {
>                        log.error("CannotCreateTransactionException:
> Hibernate transaction exception!!! Timeout.");
>                        e.printStackTrace();
>                        return EXPIRE;
>                } catch (Exception e) {
>                        log.error("Exception caught in
> readRecordView()!!!");
>                        return ERROR;
>                }
>        }
>
>
> User access goes to updateRecordView action first, and fetch data from
> database. If successful, it goes to the jsp page to show the
parameters
> and associated values. But the doubleselect tag shows only the value
of
> fist select box, second box shows the first option in from the list,
not
> the one suppose to display.
>
> Any help would be much appreciated.
>
> Many thanks,
> Jipu
>
> -----Original Message-----
> From: Felippe Scheidt [mailto:felippescheidt@gmail.com]
> Sent: Monday, November 10, 2008 12:22 PM
> To: Struts Users Mailing List
> Subject: Re: HELP!!! DoubleSeclect tag with default values
>
> Can you paste your code please?
>
> Scheidt.
>
>
> On Mon, Nov 10, 2008 at 9:04 AM, Jipu Jiang <j....@nesc.gla.ac.uk>
> wrote:
>
> > Dear all,
> >
> > I was trying to display a JSP page with some parameters from the
> > database. Everything shows up perfectly except the second dropdown
> list
> > of the doubleselect tag, which should display the value from java
> action
> > but it always shows the first value of the second list.
> >
> > For example, the first list contains countries and the second list
> > contains cities. E.g. if I select UK from the first select box, the
> > second should be London, Birmingham, Edinburgh etc.
> >
> > Now the default values of the select boxes depend on what's in the
> > database. I can get the first select box to show UK, but the second
> one
> > always shows London, which is the first one in the second list.
> Instead,
> > it should show other cities based on values in database.
> >
> > I guess it's because of javascript. Does anyone know how to deal
with
> > such problem?
> >
> > Also, when I assign values to the doubleHeaderKey and
> doubleHeaderValue
> > of doubleselect tag, the second select box shows no header at all.
How
> > can I make this work?
> >
> > Many thanks in advance,
> > Jipu
> >
> >
---------------------------------------------------------------------
> > 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: HELP!!! DoubleSeclect tag with default values

Posted by Felippe Scheidt <fe...@gmail.com>.
Hi Jipu,

Well, if i understood correctly, the second list, "tertiaryoptions" is been
completed with only one city, and there is another cities of course. The
doubleselect tag bind the two lists behind through ValueStack. For this
works correctly, verify the first list, "menu.menuoptions". This is probably
a list of MenuOption. Verify if MenuOption contains a list of
tertiaryoptions, something like this:
public class Menuoption{
...
  List<TertiaryOption> tertiaryoptions;
...
}

This is a way to doubleselect binds this two collections.

Felippe.



On Mon, Nov 10, 2008 at 2:33 PM, Jipu Jiang <j....@nesc.gla.ac.uk> wrote:

> Hi Felippe,
>
> Thank you so much for the response. Sure, here is the code:
>
> JSP:
>
> <s:form id="editRecordForm" action="updateRecord" theme="simple">
>        <table class="query-page-table">
>                <tr>
>                        <s:iterator value="sections" id="sec"
> status="secs">
>                                <table class="section-table">
>                                        <tr>
>                                                <td colspan="3">
>                                                        <h3>
>
> <s:property value="name" />
>                                                        </h3>
>                                                </td>
>                                        </tr>
>
>                                        <s:iterator value="parameters"
> id="para" status="paras">
>                                                <tr>
>                                                        <td
> class="parameter-label">
>
> <s:property value="label" />
>                                                        </td>
>                                                        <td>
>                                                                <s:if
> test="type == \"menu\"">
>
> <s:set name="menuoptions" value="menu.menuoptions"></s:set>
>
> <s:set name="tertiaryParamName" value="menu.tertiaryParamName"></s:set>
>
> <s:if test="menu.tertiary == 1">
>
> <s:doubleselect name="%{'identifier.' + paramName}"
>
> headerKey="" headerValue="--- Please Select ---"
>
> list="menu.menuoptions" listKey="value" listValue="value"
>
> doubleId="%{'editRecordForm_identifier_' + menu.tertiaryParamName}"
>
> doubleName="%{'identifier.' + menu.tertiaryParamName}"
>
> doubleList="tertiaryoptions" doubleListKey="name"
>
> doubleListValue="name" />
>
> </s:if>
>
> <s:else>
>
> <s:select name="%{'identifier.' + paramName}"
>
> listKey="value" label="%{para.label}" list="menu.menuoptions"
>
> listValue="value" emptyOption="false" headerKey=""
>
> headerValue="--- Please Select ---" theme="simple" />
>
> </s:else>
>                                                                </s:if>
>                                                        </td>
>                                                </tr>
>
>                                        </s:iterator>
>                                </table>
>                        </s:iterator>
>                </tr>
>                <tr>
>                        <td colspan="3" align="right">
>                                <br />
>                                <s:submit value="Update Record"
> theme="simple"></s:submit>
>                                <s:reset theme="simple"></s:reset>
>                        </td>
>                </tr>
>        </table>
>
> </s:form>
>
> ------------------------------------------------------------------------
> Here is the updateRecordView Method in the UpdateRecordAction.java:
>
>        public String updateRecordView() throws Exception {
>                try {
>                        this.sections =
> this.parameterManager.getSections();
>                        this.identifier =
> this.identifierManager.getIdentifierByRegisterId(this.id);
>                        return SUCCESS;
>                } catch (CannotCreateTransactionException e) {
>                        log.error("CannotCreateTransactionException:
> Hibernate transaction exception!!! Timeout.");
>                        e.printStackTrace();
>                        return EXPIRE;
>                } catch (Exception e) {
>                        log.error("Exception caught in
> readRecordView()!!!");
>                        return ERROR;
>                }
>        }
>
>
> User access goes to updateRecordView action first, and fetch data from
> database. If successful, it goes to the jsp page to show the parameters
> and associated values. But the doubleselect tag shows only the value of
> fist select box, second box shows the first option in from the list, not
> the one suppose to display.
>
> Any help would be much appreciated.
>
> Many thanks,
> Jipu
>
> -----Original Message-----
> From: Felippe Scheidt [mailto:felippescheidt@gmail.com]
> Sent: Monday, November 10, 2008 12:22 PM
> To: Struts Users Mailing List
> Subject: Re: HELP!!! DoubleSeclect tag with default values
>
> Can you paste your code please?
>
> Scheidt.
>
>
> On Mon, Nov 10, 2008 at 9:04 AM, Jipu Jiang <j....@nesc.gla.ac.uk>
> wrote:
>
> > Dear all,
> >
> > I was trying to display a JSP page with some parameters from the
> > database. Everything shows up perfectly except the second dropdown
> list
> > of the doubleselect tag, which should display the value from java
> action
> > but it always shows the first value of the second list.
> >
> > For example, the first list contains countries and the second list
> > contains cities. E.g. if I select UK from the first select box, the
> > second should be London, Birmingham, Edinburgh etc.
> >
> > Now the default values of the select boxes depend on what's in the
> > database. I can get the first select box to show UK, but the second
> one
> > always shows London, which is the first one in the second list.
> Instead,
> > it should show other cities based on values in database.
> >
> > I guess it's because of javascript. Does anyone know how to deal with
> > such problem?
> >
> > Also, when I assign values to the doubleHeaderKey and
> doubleHeaderValue
> > of doubleselect tag, the second select box shows no header at all. How
> > can I make this work?
> >
> > Many thanks in advance,
> > Jipu
> >
> > ---------------------------------------------------------------------
> > 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: HELP!!! DoubleSeclect tag with default values

Posted by Jipu Jiang <j....@nesc.gla.ac.uk>.
Hi Felippe,

Thank you so much for the response. Sure, here is the code:

JSP:

<s:form id="editRecordForm" action="updateRecord" theme="simple">
	<table class="query-page-table">
		<tr>
			<s:iterator value="sections" id="sec"
status="secs">
				<table class="section-table">
					<tr>
						<td colspan="3">
							<h3>
	
<s:property value="name" />
							</h3>
						</td>
					</tr>

					<s:iterator value="parameters"
id="para" status="paras">
						<tr>
							<td
class="parameter-label">
	
<s:property value="label" />
							</td>
							<td>
								<s:if
test="type == \"menu\"">
	
<s:set name="menuoptions" value="menu.menuoptions"></s:set>
	
<s:set name="tertiaryParamName" value="menu.tertiaryParamName"></s:set>
	
<s:if test="menu.tertiary == 1">
	
<s:doubleselect name="%{'identifier.' + paramName}"
	
headerKey="" headerValue="--- Please Select ---"
	
list="menu.menuoptions" listKey="value" listValue="value"
	
doubleId="%{'editRecordForm_identifier_' + menu.tertiaryParamName}"
	
doubleName="%{'identifier.' + menu.tertiaryParamName}"
	
doubleList="tertiaryoptions" doubleListKey="name"
	
doubleListValue="name" />
	
</s:if>
	
<s:else>
	
<s:select name="%{'identifier.' + paramName}"
	
listKey="value" label="%{para.label}" list="menu.menuoptions"
	
listValue="value" emptyOption="false" headerKey=""
	
headerValue="--- Please Select ---" theme="simple" />
	
</s:else>
								</s:if>
							</td>
						</tr>

					</s:iterator>
				</table>
			</s:iterator>
		</tr>
		<tr>
			<td colspan="3" align="right">
				<br />
				<s:submit value="Update Record"
theme="simple"></s:submit>
				<s:reset theme="simple"></s:reset>
			</td>
		</tr>
	</table>

</s:form>

------------------------------------------------------------------------
Here is the updateRecordView Method in the UpdateRecordAction.java: 

	public String updateRecordView() throws Exception {
		try {
			this.sections =
this.parameterManager.getSections();
			this.identifier =
this.identifierManager.getIdentifierByRegisterId(this.id);
			return SUCCESS;
		} catch (CannotCreateTransactionException e) {
			log.error("CannotCreateTransactionException:
Hibernate transaction exception!!! Timeout.");
			e.printStackTrace();
			return EXPIRE;
		} catch (Exception e) {
			log.error("Exception caught in
readRecordView()!!!");
			return ERROR;
		}
	}


User access goes to updateRecordView action first, and fetch data from
database. If successful, it goes to the jsp page to show the parameters
and associated values. But the doubleselect tag shows only the value of
fist select box, second box shows the first option in from the list, not
the one suppose to display. 

Any help would be much appreciated. 

Many thanks,
Jipu

-----Original Message-----
From: Felippe Scheidt [mailto:felippescheidt@gmail.com] 
Sent: Monday, November 10, 2008 12:22 PM
To: Struts Users Mailing List
Subject: Re: HELP!!! DoubleSeclect tag with default values

Can you paste your code please?

Scheidt.


On Mon, Nov 10, 2008 at 9:04 AM, Jipu Jiang <j....@nesc.gla.ac.uk>
wrote:

> Dear all,
>
> I was trying to display a JSP page with some parameters from the
> database. Everything shows up perfectly except the second dropdown
list
> of the doubleselect tag, which should display the value from java
action
> but it always shows the first value of the second list.
>
> For example, the first list contains countries and the second list
> contains cities. E.g. if I select UK from the first select box, the
> second should be London, Birmingham, Edinburgh etc.
>
> Now the default values of the select boxes depend on what's in the
> database. I can get the first select box to show UK, but the second
one
> always shows London, which is the first one in the second list.
Instead,
> it should show other cities based on values in database.
>
> I guess it's because of javascript. Does anyone know how to deal with
> such problem?
>
> Also, when I assign values to the doubleHeaderKey and
doubleHeaderValue
> of doubleselect tag, the second select box shows no header at all. How
> can I make this work?
>
> Many thanks in advance,
> Jipu
>
> ---------------------------------------------------------------------
> 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: HELP!!! DoubleSeclect tag with default values

Posted by Felippe Scheidt <fe...@gmail.com>.
Can you paste your code please?

Scheidt.


On Mon, Nov 10, 2008 at 9:04 AM, Jipu Jiang <j....@nesc.gla.ac.uk> wrote:

> Dear all,
>
> I was trying to display a JSP page with some parameters from the
> database. Everything shows up perfectly except the second dropdown list
> of the doubleselect tag, which should display the value from java action
> but it always shows the first value of the second list.
>
> For example, the first list contains countries and the second list
> contains cities. E.g. if I select UK from the first select box, the
> second should be London, Birmingham, Edinburgh etc.
>
> Now the default values of the select boxes depend on what's in the
> database. I can get the first select box to show UK, but the second one
> always shows London, which is the first one in the second list. Instead,
> it should show other cities based on values in database.
>
> I guess it's because of javascript. Does anyone know how to deal with
> such problem?
>
> Also, when I assign values to the doubleHeaderKey and doubleHeaderValue
> of doubleselect tag, the second select box shows no header at all. How
> can I make this work?
>
> Many thanks in advance,
> Jipu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

HELP!!! DoubleSeclect tag with default values

Posted by Jipu Jiang <j....@nesc.gla.ac.uk>.
Dear all,

I was trying to display a JSP page with some parameters from the
database. Everything shows up perfectly except the second dropdown list
of the doubleselect tag, which should display the value from java action
but it always shows the first value of the second list. 

For example, the first list contains countries and the second list
contains cities. E.g. if I select UK from the first select box, the
second should be London, Birmingham, Edinburgh etc. 

Now the default values of the select boxes depend on what's in the
database. I can get the first select box to show UK, but the second one
always shows London, which is the first one in the second list. Instead,
it should show other cities based on values in database. 

I guess it's because of javascript. Does anyone know how to deal with
such problem? 

Also, when I assign values to the doubleHeaderKey and doubleHeaderValue
of doubleselect tag, the second select box shows no header at all. How
can I make this work?

Many thanks in advance,
Jipu

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


Re: Struts2 upload

Posted by Nick J <ni...@gmail.com>.
Thanks to everyone who responded.
It is now working.
I removed the <interceptor-ref name="fileUpload"/> - it's not needed
I added method="post" to the HTML form element - I had forgotten it.

The extends="json-default" in the pacjage is needed because of one of the
other actions produces a JSON response.



Nick J wrote:
> 
> Hi, I am having some trouble with Uploads in Struts 2.
> Here is the action:
> <package name="uploads" extends="json-default" namespace="/_uploads">
> <!-- ...other actions ...-->
> 		<action name="imageUpload" class="uploadManager" method="imageUpload">
> 			<interceptor-ref name="fileUpload"/>
> 			<result>/upload.html</result>
> 		</action>
> </package>
> 
> Here is the HTML form:
> <form name="myForm" action="/_uploads/imageUpload"
> enctype="multipart/form-data">
>      <input type="file" name="imageUpload" value="Browse ..." />
>      <input type="submit" />
> </form>
> 
> Here's the appropriate part of the action class:
> 
> 	public String imageUpload() {
> 		return ActionSupport.SUCCESS;
> 	}
> 	
> 	public List<Image> getImageList() {
> 		return images;
> 	}
> 	
> 	public void setImageUpload(File myImage) {
> 		uploadedImage = myImage;
> 	}
> 	
> 	public void setImageUploadContentType(String contentType) {
> 		imageContentType = contentType;
> 	}
> 	
> 	public void setImageUploadFileName(String filename) {
> 		imageFilename = filename;
> 	}
> 
> I have debugger break-points in the  imageUpload method, and in the setter
> methods. 
> The execution never reaches the setters, and when it breaks in the
> imageUpload method,
> and I inspect the values of uploadedImage, imageContentType and
> imageFilename they are all null, so the interceptor has not called the the
> setters like I was expecting it to. As far as I can tell, this agrees with
> all the tutorials I've read, so I'm at a loss now. If anyone has any
> ideas, I'd be very greatful!
> 
> thanks!
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts2-upload-tp20284756p20418321.html
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