You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by DOUILLARD David <Da...@mairie-niort.fr> on 2006/07/03 09:02:05 UTC

Struts and Hibernate

Hello,

I'm working on struts and hibernate. J'ai une tache qui est affectée à un
utilisateur.

I have a Actionform named Task.

Private Integer code ;
Private String codeus ; // Login of user
Private String libelle;


I have also a POJO Task.

Private Integer code;
Private User user;  // Many-to-one relation with user Class.
Private String libelle;


And I have a action class which gets back my user's list to show it in a
combobox in my jsp when i create a task. 

Code :
<html:select property="codeus">
   <html:options property="codeus" collection="lesUtilisateurs"
labelProperty="nom">
</html:select>

The code above allows me to show a comobox with the names of my users. The
parameter sent to get back the user is codeus. Up to there, it works. After
recording in my database, my problem is to show the user allocated to the
task in modify.jsp.

If i do

Code :
<html:select property="codeus" name="tache">
   <html:options property="codeus" collection="lesUtilisateurs"
labelProperty="nom">
</html:select>

my user recording in database is not selected by default.

If I do 

<html:select property="utilisateur.codeus" name="tache">
   <html:options property="codeus" collection="lesUtilisateurs"
labelProperty="nom">
</html:select>

My user is selected, but the actionform doesn't recognize my attribute
utilisateur.codeus because it wants codeus

Does it mean that my actionform must have utilisateur.codeus as attribute ?

Thanks for your help.

David Douillard
Mairie de Niort
Direction des Systèmes d'Informations et de télécommunications 
Tél : 05.49.78.74.47 
Fax : 05.49.78.73.73 
http://www.vivre-a-niort.com <http://www.vivre-a-niort.com/> 



Re: Struts and Hibernate

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi David,

there is no default mechanism to get struts to manipulate a Hibernate pojo with child objects like that. You have to manually find the user from lesUtilisateurs and then set it on the Task. You can do the read automatically though using dot notation as you have already tried.


Adam

DOUILLARD David on 03/07/06 08:02, wrote:
> Hello,
> 
> I'm working on struts and hibernate. J'ai une tache qui est affectée à un
> utilisateur.
> 
> I have a Actionform named Task.
> 
> Private Integer code ;
> Private String codeus ; // Login of user
> Private String libelle;
> 
> 
> I have also a POJO Task.
> 
> Private Integer code;
> Private User user;  // Many-to-one relation with user Class.
> Private String libelle;
> 
> 
> And I have a action class which gets back my user's list to show it in a
> combobox in my jsp when i create a task. 
> 
> Code :
> <html:select property="codeus">
>    <html:options property="codeus" collection="lesUtilisateurs"
> labelProperty="nom">
> </html:select>
> 
> The code above allows me to show a comobox with the names of my users. The
> parameter sent to get back the user is codeus. Up to there, it works. After
> recording in my database, my problem is to show the user allocated to the
> task in modify.jsp.
> 
> If i do
> 
> Code :
> <html:select property="codeus" name="tache">
>    <html:options property="codeus" collection="lesUtilisateurs"
> labelProperty="nom">
> </html:select>
> 
> my user recording in database is not selected by default.
> 
> If I do 
> 
> <html:select property="utilisateur.codeus" name="tache">
>    <html:options property="codeus" collection="lesUtilisateurs"
> labelProperty="nom">
> </html:select>
> 
> My user is selected, but the actionform doesn't recognize my attribute
> utilisateur.codeus because it wants codeus
> 
> Does it mean that my actionform must have utilisateur.codeus as attribute ?


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