You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by netizen1 <ne...@attbi.com> on 2003/06/03 23:16:25 UTC

Advice with reading multiple html:selects

Hello,

  I have read the newsgroups regarding multiple selects.
  I have a multiple html:select control that starts out empty
  I populate the select control by using a textbox and an add button
  so it is filled dynamically.
  

  My html:select is:
  <html:select property="questionOptions" multiple="true" size="2" />

  which comes out like :
  <select name="questionOptions" multiple="multiple" size="2"
style="width:500 px; height: 61px"></select>

  I have an action Form that has:

  private String[] gstrQuestionOptions                        = null;

  public String[] getQuestionOptions()
  {
         return this.gstrQuestionOptions;
  }
  public void setQuestionOptions( String[] value )
  {
         this.gstrQuestionOptions = value;
  }

  Even in the validate i try the following
  System.out.println( getQuestionOptions().length ) and i get
  java.lang.NullPointerException

  Since the select control is dynamically populated would i have to
  use something like request.getParameterValues("questionOptions")
  instead?


  Thank you
  

-- 
Best regards,
 netizen1                          mailto:netizen1@attbi.com



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


Re[2]: Advice with reading multiple html:selects

Posted by netizen1 <ne...@attbi.com>.
Hello Varun,

Tuesday, June 3, 2003, 2:21:32 PM, you wrote:

VG> It does not matter about building it dynamically, what matter is what
VG> was selected when the form was submitted.

VG> Only the selected values are transmitted back and they should all come
VG> back in that array.



VG> -----Original Message-----
VG> From: netizen1 [mailto:netizen1@attbi.com] 
VG> Sent: Tuesday, June 03, 2003 4:16 PM
VG> To: struts-user@jakarta.apache.org
VG> Subject: Advice with reading multiple html:selects


VG> Hello,

VG>   I have read the newsgroups regarding multiple selects.
VG>   I have a multiple html:select control that starts out empty
VG>   I populate the select control by using a textbox and an add button
VG>   so it is filled dynamically.
  

VG>   My html:select is:
VG>   <html:select property="questionOptions" multiple="true" size="2" />

VG>   which comes out like :
VG>   <select name="questionOptions" multiple="multiple" size="2"
VG> style="width:500 px; height: 61px"></select>

VG>   I have an action Form that has:

VG>   private String[] gstrQuestionOptions                        = null;

VG>   public String[] getQuestionOptions()
VG>   {
VG>          return this.gstrQuestionOptions;
VG>   }
VG>   public void setQuestionOptions( String[] value )
VG>   {
VG>          this.gstrQuestionOptions = value;
VG>   }

VG>   Even in the validate i try the following
VG>   System.out.println( getQuestionOptions().length ) and i get
VG>   java.lang.NullPointerException

VG>   Since the select control is dynamically populated would i have to
VG>   use something like request.getParameterValues("questionOptions")
VG>   instead?


VG>   Thank you
  


Belive it or not your response helped me figure it out.  I added them
but i when i submit they werent highlighted.  But if i check highlight
them then i get the valid answer.

Thanks

-- 
Best regards,
 netizen1                            mailto:netizen1@attbi.com



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


RE: Advice with reading multiple html:selects

Posted by Varun Garg <va...@yahoo.com>.
It does not matter about building it dynamically, what matter is what
was selected when the form was submitted.

Only the selected values are transmitted back and they should all come
back in that array.



-----Original Message-----
From: netizen1 [mailto:netizen1@attbi.com] 
Sent: Tuesday, June 03, 2003 4:16 PM
To: struts-user@jakarta.apache.org
Subject: Advice with reading multiple html:selects


Hello,

  I have read the newsgroups regarding multiple selects.
  I have a multiple html:select control that starts out empty
  I populate the select control by using a textbox and an add button
  so it is filled dynamically.
  

  My html:select is:
  <html:select property="questionOptions" multiple="true" size="2" />

  which comes out like :
  <select name="questionOptions" multiple="multiple" size="2"
style="width:500 px; height: 61px"></select>

  I have an action Form that has:

  private String[] gstrQuestionOptions                        = null;

  public String[] getQuestionOptions()
  {
         return this.gstrQuestionOptions;
  }
  public void setQuestionOptions( String[] value )
  {
         this.gstrQuestionOptions = value;
  }

  Even in the validate i try the following
  System.out.println( getQuestionOptions().length ) and i get
  java.lang.NullPointerException

  Since the select control is dynamically populated would i have to
  use something like request.getParameterValues("questionOptions")
  instead?


  Thank you
  

-- 
Best regards,
 netizen1                          mailto:netizen1@attbi.com



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



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