struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gawain Hammond" <gawain.hamm...@192.com>
Subject [S2] Does struts set null values for pojo fields?
Date Wed, 20 Aug 2008 15:30:14 GMT
Hi,

I have tried to RTFM as much as possible but I can't work out how I
might solve this issue, and was hoping someone could point me in the
right direction. I've tried quite a few possible different options but
I'm now running out of ideas.

I'm using a select tag in a User form to set the User's Group field, and
I want to be able to make it null if the select option has nothing
selected. I've read plenty of docs, but I can't work out how this might
be possible. I presumed until recently this was what the
emptyOption="true" was for?

Everything else works just great, I can select a Group fine. But if I
try to select the header value (or use emptyOption="true") to not
specify a group, struts creates a 'new Group()' object for the
user.group pojo field and the Group object has null values, instead of
the user.group object being left as the default of null.

Ideally, I would like to be able to tell struts not to do this, It would
be awesome after a submit if the user.getGroup() method returned a null
value instead (I'm using hibernate to persists the object and this would
make life nice and straight forward).


Here's my select tag (which works if I select a value, just not if I
select the emptyOption or headerValue):

<s:select label="Group" headerKey=""
headerValue="-- None --"
name="user.group.id"
value="%{user.group.id}"
list="%{#groupAction.list}"
listKey="id" listValue="name"
/>


Does anyone know if this can be done? Can I configure struts to set
user.group as null rather than create an empty Group object if no
id/value has been specified in the drop down select box?

Is this something that is working as desired, and I'm the one who needs
to change? Or does struts maybe needs a new feature request in jira?


Many thanks for any assistance in advanced...
----------------------------------------------------------
This transmission is strictly confidential, possibly legally privileged, and intended solely
for the 
addressee.  Any views or opinions expressed within it are those of the author and do not necessarily

represent those of 192.com, i-CD Publishing (UK) Ltd or any of it's subsidiary companies.
 If you 
are not the intended recipient then you must not disclose, copy or take any action in reliance
of this 
transmission. If you have received this transmission in error, please notify the sender as
soon as 
possible.  No employee or agent is authorised to conclude any binding agreement on behalf
of 
i-CD Publishing (UK) Ltd with another party by email without express written confirmation
by an 
authorised employee of the Company. http://www.192.com (Tel: 08000 192 192).  i-CD Publishing
(UK) Ltd 
is incorporated in England and Wales, company number 3148549, VAT No. GB 673128728.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message