You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by José María Tristán <jt...@sedasolubles.com> on 2006/02/10 18:20:04 UTC

Problem whith html:optionscollection

Hi,

	I have a bean form:


import java.util.*;

import org.apache.struts.action.ActionForm;
import org.apache.struts.util.LabelValueBean;

public class CustomSubmitForm extends ActionForm {

	private String m_firstName   = null ;
	private String[] m_countryCode;

	private List lCountryCode = new ArrayList();

	private List m_countryOptions = null;

	public String getFirstName() {
		return m_firstName ;
	}

	public String[] getCountryCode(){
		System.out.println("getCountryCode; " + m_countryCode);
		return m_countryCode;
	}

	public void setCountryCode(String[] m_countryCode){
		this.m_countryCode = m_countryCode;
	}

	 public Collection getCountryOptions() {
	        if (m_countryOptions == null) {
	            m_countryOptions = new Vector(2) ;
	            m_countryOptions.add(new LabelValueBean("United States","US"))
;
	            m_countryOptions.add(new LabelValueBean("Germany","DE")) ;
	            m_countryOptions.add(new LabelValueBean("España","ES"));
	           }

	        return m_countryOptions;
	 }


and a jsp:
	<html:form action="submit.do">
				ListEdad:
					<html:select property="countryCode" multiple="true">
					    <html:optionsCollection property="countryOptions" />
					</html:select>
				<br>


				<html:submit/>
	</html:form>

This is ok, but how i can select per example Germany and United States per
defect?

Thank you.




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