Problem initializing (pre-selected) html:select multiple=true

2001-07-25 Thread Xavier Brunel

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




Re: Problem initializing (pre-selected) html:select multiple=true

2001-07-25 Thread dhay



Hi.   If you want Struts to display values pre-selected, you should leave off
the value= on the select tag altogether.

I haven't tried it with multiple=true, but use  html:select
property=category to display the value I previously assigned in my form
under category.  Would assume it would work with multiple=true too...

Cheers,

Dave





Xavier Brunel [EMAIL PROTECTED] on
07/25/2001 10:57:14 AM

Please respond to [EMAIL PROTECTED]

To:   'Struts-User [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  Problem initializing (pre-selected)  html:select multiple=true



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