You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by manishbel <ma...@yahoo.com> on 2008/04/08 16:40:15 UTC

Preparable Question

Hello,

I am trying to use the Preparable but having some problems while the page is
being rendered. I will try my best to explain the problem, please ask if you
need more information as i might not be able to accurately  explain the
problem as i am pretty new to struts2.

Scenario:
User should be able to create the EmailDistributionList and create email
Addresses under it.

My first attempt is to be able to create the Group Itself . So i introduced
an action which implements Preparable interface. 

The Action provides 
1.)  List of currently avaialable groups- displayed as dropdown on the
screen. 
2.)  has a group id based on which it tries to decide whether to load data
from the databse or not. e.g. if the user
     lands for the first time on the page there would be no id in the rquest
hence the id would not have any data in 
     it. it is similar to the CRUD example on struts website. 

Creation and saving of the group went ok, the problem occured when i load
the data from the databse and try to display it on the screen. 

i have defined just one action in struts.xml to accomplish this. when the
user arrives for the first time through the menu item which is of course a
get request , the user is provided with list of available groups and a blank
description field (since it does not have any id in the request).

When the user changes selection in the drop down i do a post to the same
action which binds the id to group id field in the action. It works ok as
far as it has the id in the request and loads the data from the databse and
stuff. but as soon as it reaches the screen and when it tries to extract
data out of the domain it wipes out the fields from the group domain, e.g.
If the Group had id name and description, and i try to display the
description on the page like <s:textarea name="group.description"/> the page
shows nothing in it even though the id was passed to the action and logger
statements show that the group has the description on the server side. 

I used <s:debug/> tag to see more information but even in that information
it shows that the description is blank. I am trying to solve this problem
for a long time but have been unsuccessful in resolving it, your help would
be greatly appreciated. 


Thanks
Manish.
-- 
View this message in context: http://www.nabble.com/Preparable-Question-tp16559041p16559041.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: Preparable Question

Posted by Laurie Harper <la...@holoweb.net>.
manishbel wrote:
> Hello,
> 
> I am trying to use the Preparable but having some problems while the page is
> being rendered. I will try my best to explain the problem, please ask if you
> need more information as i might not be able to accurately  explain the
> problem as i am pretty new to struts2.
> 
> Scenario:
> User should be able to create the EmailDistributionList and create email
> Addresses under it.
> 
> My first attempt is to be able to create the Group Itself . So i introduced
> an action which implements Preparable interface. 
> 
> The Action provides 
> 1.)  List of currently avaialable groups- displayed as dropdown on the
> screen. 
> 2.)  has a group id based on which it tries to decide whether to load data
> from the databse or not. e.g. if the user
>      lands for the first time on the page there would be no id in the rquest
> hence the id would not have any data in 
>      it. it is similar to the CRUD example on struts website. 
> 
> Creation and saving of the group went ok, the problem occured when i load
> the data from the databse and try to display it on the screen. 
> 
> i have defined just one action in struts.xml to accomplish this. when the
> user arrives for the first time through the menu item which is of course a
> get request , the user is provided with list of available groups and a blank
> description field (since it does not have any id in the request).
> 
> When the user changes selection in the drop down i do a post to the same
> action which binds the id to group id field in the action. It works ok as
> far as it has the id in the request and loads the data from the databse and
> stuff. but as soon as it reaches the screen and when it tries to extract
> data out of the domain it wipes out the fields from the group domain, e.g.
> If the Group had id name and description, and i try to display the
> description on the page like <s:textarea name="group.description"/> the page
> shows nothing in it even though the id was passed to the action and logger
> statements show that the group has the description on the server side. 
> 
> I used <s:debug/> tag to see more information but even in that information
> it shows that the description is blank. I am trying to solve this problem
> for a long time but have been unsuccessful in resolving it, your help would
> be greatly appreciated. 

Firstly, this doesn't appear to have anything to do with the Preparale 
interface, it would seem to be a problem with data rendering (since you 
say the group is retrieved correctly).

Start with the basics:

- Does you action have a getGroup() getter defined?
- Does it correctly return the group loaded from the database?
- Does the group returned by getGroup() actually contain data?

I'd suggest adding some logging in your getGroup() method to confirm 
that it's really returning the data you think it should be. If that 
checks out, there's likely a problem in your JSP somewhere.

L.


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