You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Xavier Brunel <xa...@profileup.com> on 2001/07/25 16:57:14 UTC

Problem initializing (pre-selected)

Hello,

I have a problem with multiple <html:select> struts tag initialization.
I am unable to initialize the select tag with the values i retrieve
from my database.

I have a JSP with
	- a <html:select> multiple who will retrieve the selected compagnies I
choose.
	- a <html:options> containing all the compagnies in my database

I have in the Form associated with this JSP :
	- an attribut rattacheInitialChoisi who retrieve a String[] of compagnies
already choosen
	- an attribut listeSociete who retrieve a ArrayList of all compagnies
	- an attribut rattacheSocieteChoisie who will retreive a String[] of the
new chosen compagnies

All these attributs are correctly initialized (I saw this in my logs files)

But I am unable to initialize the selected elements of my <html:select> list
in the jsp thanks to the "rattacheInitialChoisi" attribut (pre-selected the
select list when the jsp appears)!!!!

Has anyone experimented this and have an idea of how to do so ???
HELP !!!!

Here is my code
----------------------------------------------------------------------
SiteDetailForm.java

private ArrayList listeSociete = new ArrayList() ;
private String[] rattacheSocieteChoisie= new String[0];
private String[] rattacheInitialChoisi = new String[0] ;

public void setListeSociete(ArrayList _listeSociete)
	{
		this.listeSociete = _listeSociete;
	}
public ArrayList getListeSociete()
	{
		return this.listeSociete;
	}
public void setRattacheSocieteChoisie(String[] _rattacheSocieteChoisie)
	{
		this.rattacheSocieteChoisie = _rattacheSocieteChoisie;
	}
public String[] getRattacheSocieteChoisie()
	{
		return this.RattacheSocieteChoisie;
	}
public void setRattacheInitialChoisi(String[] _rattacheInitialChoisi)
	{
		this.rattacheInitialChoisi = _rattacheInitialChoisi;
	}
public String[] getRattacheInitialChoisi()
	{
		return this.rattacheInitialChoisi;
	}
----------------------------------------------------------------------------
---
----------------------------------------------------------------------------
---
SiteDetail.jsp

<bean:define name="SiteDetailForm" property="listeSociete" id="lidy"/>
<bean:define name="SiteDetailForm" property="rattacheInitialChoisi"
id="initial" type="java.lang.String[]"/>
<html:select property="rattacheSocieteChoisie" value="initial"
multiple="true" size="2">
	<html:options property="idSociete" collection="lidy"
labelProperty="raisonSociale"/>
</html:select>

----------------------------------------------------------------------------
---

Xavier Brunel
France