struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "PREETAM Balijepalli" <BPree...@covansys.com>
Subject RE: html:option - is there a selected option attribute?
Date Mon, 23 Jun 2003 12:49:06 GMT
did that solve ure problem

-----Original Message-----
From: Natalie D Rassmann [mailto:natalie.d.rassmann@lmco.com]
Sent: Monday, June 23, 2003 6:03 PM
To: Struts Users Mailing List
Subject: Re: html:option - is there a selected option attribute?


This isn't going to work or at least I am not sure how it will because it isn't a reset problem.
 In the formbean, I have as part of the property for the list what list item is selected.
 For example, 

I have a DynaValidatorForm property called changeType.  changeType is of the type OptionsBean.



OptionsBean looks like this.... 


options - ArrayList of  int OptionId and String OptionLabel 
selectedId - int 


The jsp code to build the list is below: 


 <td colspan="2"> 
         <B><bean-el:message key="label.revRec.chngType" bundle="PRTR_RESOURCE_KEY"/>:</B>

            <html-el:select name="reviewRecordForm" property="changeType.options"> 
        <c:forEach items="${reviewRecordForm.map.changeType.options}" var="changeTypeOption">

           <html-el:option value="${changeTypeOption.optionId}"> 
                 <c:out value="${changeTypeOption.optionLabel}"/></html-el:option>

        </c:forEach> 
            </html-el:select> 
      </td> 


This code will render the following in the resulting html file: 


<td colspan="2"> 
         <B>Change Type:</B> 
            <select name="changeType.options"><option value="1">non-SC</option>



           <option value="2">SC</option></select> 
      </td> 


However, I want to be able to render the following: 


<td colspan="2"> 
   <B>Change Type:</B> 
   <select name="changeType.options"> 
     <option value"1" selected>non-SC</option> 
    <option value="2">SC</option> 
 </select> 
</td> 


I will use the selectedId from the OptionsBean to set the selected option in the list. 


How do I do this??   I don't think the overriding the reset method is the answer?? 


Filip Polsakiewicz wrote: 


Your formbean will be resetted on the first use and then every time you 
submit your form. 
  -----Original Message----- 
  From: Natalie D Rassmann [ mailto:natalie.d.rassmann@lmco.com] 
  Sent: Monday, June 23, 2003 1:26 PM 
  To: Struts Users Mailing List 
  Subject: Re: html:option - is there a selected option attribute? 


  This will only work if I am reseting....  In the formbean, I have the 
selected option.  I want to extract that information and mark the 
appropriate list item as selected.  When I look in the tld, I do not see a 
selected attribute as part of the option tag.  How do I set the selected 
attribute.... 
  <select,,,, 
    <html:option value="" selected=selected>XXXX</option> 
   <html:option value="">YYYY</option> 
  </select> 


  Filip Polsakiewicz wrote: 


      Sorry i was sleeping :-) I thought you were talking of checkboxes. 
Well 
    i'd say it's not much different. In your formbeans reset method just set 
      the corresponding property (the property which is returned by your 
    selectbox) to the value you would like to be the default. 


      Greetz, Filip 


       -----Original Message----- 
      From: Natalie D Rassmann [ mailto:natalie.d.rassmann@lmco.com] 
      Sent: Monday, June 23, 2003 1:13 PM 
      To: Struts Users Mailing List 
      Subject: Re: html:option - is there a selected option attribute? 


      You lost me; what corresponding boolean value?? 
      Filip Polsakiewicz wrote: 


        Hi, 
        i had the same problem. Here is the solution. You have to set the 
        corresponding boolean value to true 


        HTH Filip 


        > -----Original Message----- 
        > From: Natalie D Rassmann [ mailto:natalie.d.rassmann@lmco.com] 
        > Sent: Monday, June 23, 2003 12:52 PM 
        > To: Struts Users Mailing List 
        > Subject: html:option - is there a selected option attribute? 
        > 
        > 
        > I have an Options List and I want to make one of the items in the 
    select 
        > list selected.  I am using the html-el tags.  How do I mark an 
option 
    as 
        > selected??  Is there a way: 
        > 
        > Thanks in advance, 
        > 
        > Natalie 
        > 
        > 


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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message