Indexed Property, html:select

Hello,
Dev. Env. : JSP/Struts - Indexed Properties
<c:forEach var="lines" items="${MbrLines.map.lines}">
<td>
<html:select name="lines" indexed="true" property="loc" >
<%
StringBuffer sb = new StringBuffer();
DBAccess dba = new DBAccess();
sb = dba.fillDropdown("ALLLOC",0,"");
out.println(sb);
%>
</html:select>
</td>
</c:forEach>
This is the code I have in a JSP used for edits. I fill the dropdown with all available locations(e.g. Chicago, Miami etc) from a database table.
How do I set the current value in the record to be edited, say "Chicago", to be "selected" in the dropdown? Or, is there a way to pass the property�s current value to the DB method ?
Any help is greatly appreciated. Thanks in advance.

the HTML generated as folllows:
as you may see, the bean has been interpreted to array, which I have correspondent set method in form. Please check the code for form in my previous post.
If I radio button of any row, it sets all the rows. which looks very strange to me, because it shows to me that the beans has been seperated by using different names. as poDisplayVO[0] ; poDisplayVO[1] ; poDisplayVO[2.
<! ------------------------ html genterated ------------------------------------------------>
<tr>
<td>
Accounting Studies
</td>
<td>
<input type="radio" name="poDisplayVO[0].fosVO.select" value="Accounting">
Accounting
</td>
<td>
<input type="radio" name="poDisplayVO[0].fosVO.select" value="no"> NO
</td>
<td>
<input type="radio" name="poDisplayVO[0].fosVO.select" value="yes"> YES
</td>
</tr>
<tr>
<td>
Accounting Studies
</td>
<td>
<input type="radio" name="poDisplayVO[1].fosVO.select" value="Bookkeeping">
Bookkeeping
</td>
<td>
<input type="radio" name="poDisplayVO[1].fosVO.select" value="no"> NO
</td>
<td>
<input type="radio" name="poDisplayVO[1].fosVO.select" value="yes"> YES
</td>
</tr>
<tr>
<td>
Accounting Studies
</td>
<td>
<input type="radio" name="poDisplayVO[2].fosVO.select" value="Computerized Accounting(Duplicate)">
Computerized Accounting(Duplicate)
</td>
<td>
<input type="radio" name="poDisplayVO[2].fosVO.select" value="no"> NO
</td>
<td>
<input type="radio" name="poDisplayVO[2].fosVO.select" value="yes"> YES
</td>
</tr>

Similar Messages

  • Html:select doesnt set the form property if there is no option tag

    Hello,
    I have a select box that I am dynamically populating through ajax.
    I have it populated in the create screen. I save the form elements saved. I am able to get the data on a detail screen when i do a bean:write
    But when i try to see the selected element on the edit screen. The bean doesnt get populated
    Here is my code:
         <tr>               
    <td >Region:</td>
         <td>                              <html:select name="matterCreateForm" property="region" styleId="regionListBox">
         </html:select>
         </td>
         </tr>
    Can somebody help me with this. If i do an alert of region in javascript it is empty though the form element has a value.
    If I remove the entire select code and use a html:hidden fot the property. It alerts me with the value.
    Your help is appreciated!
    Thanks
    Priya

    After your SQL SELECT on CO_EditForm.cfm, you need a
    <CFIF> that checks to see if any records were retrieved. See
    below.

  • How to get the values from html:select? tag..?

    i tried with this, but its not working...
    <html:select styleClass="text" name="querydefs" property="shortcut"
                 onchange="retrieveOptions()" styleId="firstBox" indexed="true">
    <html:options collection="advanced.choices" property="shortcut" labelProperty="label" />
    </html:select>
                        <td align="left" class="rowcolor1">
                        <script language="javascript" type="text/javascript">
                              function retrieveOptions(){
                             var sel = document.querydefs.options;
                             var selectedOption = sel[sel.selectedIndex].value;
                             document.write(selectedOption);
                           </script>

    <td align="left" class="rowcolor1">
                        <script language="javascript" type="text/javascript">
                              function retrieveOptions(){
                             var sel = document.querydefs.options;
                             var selectedOption = sel[sel.selectedIndex].value;
                             document.write(selectedOption);
                           </script>This java script is not working at all..its not printing anything in document.write();
    This is code..
    <td class="rowcolor1" width="20%">
    <html:select styleClass="text" name="querydefs" property="shortcut"
                             onchange="retrieveSecondOptions()" styleId="firstBox"
                             indexed="true">
                             <html:options collection="advanced.choices" property="shortcut"
                                  labelProperty="label"  />
                        </html:select>i tried with this also. but no use..i'm not the getting the seleced option...
    function retrieveOptions(){
    firstBox = document.getElementById('firstBox');
                             if(firstBox.selectedIndex==0){
          return;
        selectedOption = firstBox.options[firstBox.selectedIndex].value;
    }actually , how to get the values from <html:select> ...?
    my idea is to know which value is selected from the combo box(<html:select> ) if that value is equal some string i have enable a hyperlink to open a popup window

  • Html:select inside logic:iterate

    hi,
    I am having a string type corresponding to the select attribute in my form bean. Since this select tag is inside the logic:iterate all the names of the select boxes are same. i.e myLabel in this context. So, how can i set the value to select box. do i need to change the data type for labelValue in form bean.
    my form bean is given below:
    here the listTotal is the total of the combo and listValue is the individual combo
         public ArrayList listTotal;
         public Collection getListTotal()
              return (Collection)listTotal;
         public void setListTotal(ArrayList total)
              this.listTotal = total;
         public ArrayList listValues;
         public void setListValues(ArrayList values)
                   this.listValues = values;
         public ArrayList getListValues()
              return  listValues;
                         String myLabel;
         public String getMyLabel()
         return myLabel;
         public void setMyLabel(String myLabel)
         this.myLabel = myLabel;
    And i m setting the values in the action class
              ArrayList listTotal = new ArrayList(1);
              ArrayList listValues = new ArrayList();
              listValues.add(new LabelValueBean("k1", "Value1"));
              listValues.add(new LabelValueBean("k2", "Value2"));
              listValues.add(new LabelValueBean("k3", "value3"));
              listTotal.add(listValues);
              listValues = new ArrayList();
              listValues.add(new LabelValueBean("l1", "Value4"));
              listValues.add(new LabelValueBean("l2", "Value5"));
              listValues.add(new LabelValueBean("l3", "value6"));
              listTotal.add(listValues);
              listValues = new ArrayList();
              listValues.add(new LabelValueBean("m1", "Value7"));
              listValues.add(new LabelValueBean("m2", "Value8"));
              listValues.add(new LabelValueBean("m3", "value9"));
              listTotal.add(listValues);
              employeeForm.setListTotal(listTotal);
    jsp code
    <logic:iterate id="listValues" name="EmployeeForm" property="listTotal" indexId="index">
    <tr><td>
    <html:select property="myLabel" >
    <html:options collection="listValues" labelProperty="label" property="value"/>
    </html:select>
    </logic:iterate>

    hi,
    instead of having it as a array i thought of going for an array list so that the manipulation would be much easier. ok here is my code.
        //This is the array list for names of the drop downs.
        private ArrayList selectedList;
        public ArrayList getSelectedList()
            return selectedList;
        public void setSelectedList(ArrayList pselectedList)
           this.selectedList = pselectedList;
        public ListValueVO getSelected(int index)
           return (ListValueVO) selectedList.get(index);
        }I have already mentioned in my previous posts that i have 3 lists in my form bean. One list for individual combo box. Another list for total number of combo boxes. The third list for the names of the combo boxes. Pls let me know whether i m going in the correct direction or not.

  • Can i use id on html:select syntax...

    Hi,
    i am using the following code to take data from the database directly to a dropdown box.
    <html:select property="lddate" style = "width:160">
    <html:option value="--SELECT--">SELECT</html:option>
    <html:options collection="loadDateList" name="almRecordsNotProcessedBO" property="lddate"
    labelProperty="lddate"/>
    </html:select>
    then after selecting the load-date from the drop-down box & clkng on submit button page is wrkng fine but in the dropdown it not showing the selected date.it is showing the default 1st entry in the drop-down box.
    Now i using a javascript for showing the selected date::::
    <script type="text/javascript">
    function getText(){
    var x=document.getElementById("aSelectControl")
    alert(x.options[x.selectedIndex].text)
    </script>
    But here i needed an id . In my Drop-down select code where i shuld use this id..i dont understand..i have checked for syntax of html:select but there is no id tag attribute of html:select.can anyone suggest me any other idea how to show that.
    can any one help me ..its very very urngent. i got stuck..plzzzz
    I have checked in the internet there is a select syntax where i can make use that id..
    Select the load date:
    <select id="aSelectControl">
    <option>25-12-2011</option>
    <option>26-11-2011</option>
    <option>27-11-2011</option>
    </select>
    But here the problem is i have to write the dates in a jsp page..but its not poss for my case...i have to take the date from databse. can any one tell me if i using the above query how to take data from the database.
    plzzzz help me..

    can anyone say where i am wrong in follwing syntax..
    function changeText2(val){
         var index = document.getElementById('prodlvl0').selectedIndex;
         alert("value="+document.getElementById('prodlvl0').value);
    alert("text="+document.getElementById('prodlvl0').options[index].text);
    <td class = "almtdheight" width="37%">
    <html:select property="lddate" style = "width:160" styleId="prodlvl0" onclick="changeText2(this.value)">
    <html:option value="--SELECT--">SELECT</html:option>
    <html:options collection="loadDateList" name="almRecordsNotProcessedBO" property="lddate" labelProperty="lddate"/>
    </html:select>
    </td>
    its not wrkng...

  • Problem with html:select or html:options tags using struts,jsp and tomcat

    Hi
    I'm updating a Struts-Project to a new layout and therefore rework all jsp Sites.
    I'm also using a new Folder-Structure and update therefore my struts-config file.
    My Problem now is:
    Till now, we had a select-field with a code like this:
    < html:form action="/timetableAction" method="POST">
    < table width="53%" border="0">
    < tr>
    < td>< html:radio property="dauer" value="semester"
    /></ td>
    < html:select property="semester" size="1">
    < htmlptions name="semesterList" />
    </ html:select>
    </ html:form>
    The problem now is, that whenever I use any <html:xy> tag, the tomcat server I use can not show the page, he shows just the headers of the template, but not the
    content.-jsp-File where the form would be in. He stops right in the middle of the html page, when he notices the <html:xy> tags.
    And the funny thing is, that he has no problem to show a page when there is a <html:errors> within it? Why could this be? the struts-html.tld File is well included and teh Tomcat Server shows no exceptions.
    Waiting for you answers and thanks

    Thank you, I already got the answer in another forum

  • Problem in submiting the form onchange of html:select

    I am using WSAD 5.0 and working on a small application with struts.
    I have following code where I want to submit the form if user selects any option from the list. Problem is when i select any option it is giving error that this property is not supported. Following is my code
    <html:form action="/NewUserAction1">
    <tr>
                   <td>
                        <font color="Blue">
                             <b><bean:message key="NewUser1.CountryName" /></b>
                        </font>*
                   </td>
                   <td>
                        <html:select property="state" onchange="submit();">
                             <html:option value="default">select state</html:option>
                             <html:option value="bangalore">Bangalore</html:option>
                             <html:option value="delhi">Delhi</html:option>
                        </html:select>
                   </td>
              </tr>
         </html:form>
    Please help me someone why i am not able to submit the form on onchange event of <html:select>
    Thanks.

    I got the solution :)
    Finally I figured out that
    by default, struts gives <html:submit/> tags a name of
    "submit". Thus there was a namespace collision in the
    form object, with the submit button overriding the
    form's submit method. I fixed the problem by changing
    the name of the submit button. Something like this
    works great:
    <html:submit property="submitPage">
                        <bean:message key="NewUse1.Submit"/>
                   </html:submit></td>
    Now i am able to submit the form.
    Thanks alot.

  • Use of titleKey attribute in html:select tag

    Hi,
    There is one "titleKey" attribute to create mouse over pop-up texts taking key values from property files in case of i18n. It works for every struts specific tag like <html:text titleKey="help.rmc.name"/> or <html:checkbox titleKey="help.rmc.name"/> except for <html:select> tag which is used for creating combo box or list box. But this tag contains the titleKey attribute.
    Please give me some suggestions how to implement this mouse over pop-up texts in case of <html:select> tag

    Hi,
    There is one "titleKey" attribute to create mouse over pop-up texts taking key values from property files in case of i18n. It works for every struts specific tag like <html:text titleKey="help.rmc.name"/> or <html:checkbox titleKey="help.rmc.name"/> except for <html:select> tag which is used for creating combo box or list box. But this tag contains the titleKey attribute.
    Please give me some suggestions how to implement this mouse over pop-up texts in case of <html:select> tag

  • How to display html:select in Edit page using same options as in Add page

    Hi,
    <html:select property="tblAssociateDetailsVisaType">
                <html:option value="H1">H1</html:option>
    </html:select>I want small help -
    I have two functionalities 1.add 2.Update
    In Add i have nearly 10 dropdown lists with average 20 options, when i submit into DB stored a single record.
    Now when i want to Edit that same record , i am just getting the value from DB and displaying as <td><html:text property="tblAssociateDetailsVisaType" value="<%=VisaType_page%>" size="10"/> which is a wrong way!
    But, i am struggling in showing the same dropdown list with all the option with the option retrieved from the DB on top with <html:select ..... selected>!
    Please help me how to do ?
    I would like to make you of .properties file in doing so ! Which avoids recompiling!
    Thanks in advance!
    Edited by: ganeshtyarala on Dec 17, 2007 11:57 AM

    You could store all of the options in a collection and then loop through it and compare it to the value that was returned. (collection contains beans with value and label attribute)
    This is the code I use.. it is using JSTL tags, but you could implement the same using other methods.
    When my application loads I query the database to get the possible values for the drop down and then load them into the the form.
    <div class="fieldSpan">
    <select name="rewardTypeCode" id="rewardTypeCode">
              <c:forEach var="rewardTypeCodes" items="${sessionScope.myActivity.rewardTypeCodeList}">
                   <option <c:if test="${sessionScope.myActivity.rewardTypeCode == rewardTypeCodes.value}">selected</c:if>
                        value="${rewardTypeCodes.value}">${rewardTypeCodes.value} - ${rewardTypeCodes.label}</option></c:forEach></select></div>

  • Passing collection in JSTL html:select onChange event javascript

    I'm trying to pass an object from the form to a javascript function to change text box values when the value of a select field is changed.
    On the jsp page, I have access to the collection called rows.
    I also have an html:select field that I need to use the onChange event to change other fields on the page. I can certainly call a javascript function on the onChange with no problem. But I need to take it one step further. I need to send the javascript function the collection called rows, so I can set other fields' values on the jsp page to the values of the selected row.
    This (or some facimile) is what I want to do:
    <html:select name="currentForm" property="value(id)" onChange="fillUomForm(this.form,this,rows);">
      <c:forEach var="row" items="${rows}">
          <c:choose>
               <c:when test='${row.id == currentForm.stringValues["id"]}'>
                    <option value="<c:out value='${row.id}'/>" selected>
                         <c:out value="${row.id}"/>
                    </option>
               </c:when>
               <c:otherwise>
                     <option value="<c:out value='${row.id}'/>">
                        <c:out value="${row.id}"/>
                     </option>
               </c:otherwise>
           </c:choose>
        </c:forEach>
    </html:select>Of course, rows is not recognized when I try to run this.
    I have tried replacing rows with
    <c:out value='${rows}'/> but that did not work.
    How can I do this?
    thanks,
    Walter

    sigh.
    Another user mixing up JAVA and javaSCRIPT.
    Java runs on the server. It generates an HTML page, and stops running.
    When the client receives the HTML page it can start running javascript.
    The only way java code is run again is if you make another http request. - ie the next time you click a link or submit a form.
    Most of the time that results in reloading a new page.
    You have two options
    1 - Download all the information you might possibly want/need as part of the JSP page. Then the javascript onclick event can retrieve it from javascript memory.
    2 - Make the onchange event submit an HTTP request, and then pick up the response, and do with it what it will. AJAX is a technology that lets you update the page without refreshing it completely.
    Hope this helps,
    evnafets

  • Indexed property - editor needed?

    Folks,
    I have a bean (MyBean) with a indexed property (array of class type ClassX). It has setter and getters (total of 4) according to Java Beans specification.
    On Netbeans, the indexed property appears on Properties list. But, I can�t add itens to it, like it occurs when the property is not indexed or is a String indexed property. I think I should assign an 'editor' to it.
    Does anybody knows how to do this?
    The idea is: the ClassX is a JComponent and the Frame has some of them (10, for example). This indexed property from MyBean should allow users to add as many as they want, but limited to those already added to the Frame. They could add, for example, 4 of 10 to the array.
    Thanks!

    Did you try selecting portal components like books, pages, portlets. I have seen this problem too. But it would go away when you restart workshop.
    --SJ                                                                                                                                                                                                                                                                                                               

  • Html:select - very confusing

    I am having a lot of difficulty understanding how the html:select works - especially if you're working with different ypes of containers e.g. hashmaps, lists, collections. I'm especially having trouble with lists. Here's what I have (I'm building a struts application):
    Action Class
    List bdates = dbconfig.getBusinessDates();
    httpServletRequest.getSession().setAttribute("BusinessDates", busDates );JSP Page
    <%@ page import "import java.util.List" %>
    <%
    List getBusDates = (List) session.getAttribute("BusinessDates");
    request.setAttribute("busDate", getBusDates);
    %>
    <html:select property="businessdate">
            <html:options collection="busDate" property="bdate"/>
    </html:select>I get an error saying no get property found for bdate in bean. So then I manually go to my ActionForm for this JSP page and add bdate as a string variable and its getter and setter functions. But it still doesnt work.
    Can someone please explain to me how I can use a List with an Html:select and html:option tags in JSP?
    Any assistance much appreciated.

    1) There's no need to pull the collection out of the session and put it in the request...
    <html:options collection="BusinessDates" scope="session" property="bdate" labelProperty="bdateLabel" />
    2) The property and labelProperty values are used to map to fields in the objects that are in the list. It doesn't matter what is in the list, as long as those classes have methods:
    public String getBdate() {
       return ...;
    public String getBdateLabel() {
       return ...;
    }

  • HTML:Select

    Hi,
    I am having a list of names from DB which I should show in the muliselect box. I have a form bean which has a String array with the names to be shown.
    I have written like this...but dont know if im correct
    <html:select name="nameForm" property="nameList"  multiple="true">
    <html:options collection="nameList" property="name" labelProperty="name"/>
    </html:select>                    Now my question is in html select should the attribute property also point to the name of the arraylist. and collection should also point to arralist?
    How it should be written...can you please help...
    Thanks

    In form bean I have
    String[] namesList;
    public String[] getNamesList(){
    xxxxxx ;
    public setNamesList(){
    xxx;
    }in this case the property is also namesList and collections should also point to the list which is namesList. Is this correct?

  • html:select Struts tag problems

    hello
    I've a bean "Profile" in my sessionScope under name "myProfile"
    This bean is defined as
    public class Profile implements java.io.Serializable  {
         private User user;
         private List<Groups> groups;
         private List<Function> function;
         private List<Services> services;
         etc. .-.... getter and setter.....
    }the "services list" is full of data
    now in my jsp I want to print all the services in a select box. I'm using struts so I do
    <html:select property="serviceId">
          <html:options collection="${myProfile.services}" property="idSoc" labelProperty="descrizione" />
                        </html:select>it doesn't works..the console says
    Cannot find bean under name [it.object.Services@16b5518, it.object.Services@19fdafc]
    I've read the documentation.. but I don't understand if in the collection attribute I can put only the name of a bean that identify a collection...
    I can't use EL?
    I try do use a bean:define and to put its name in the collection attribute
    <bean:define id="myBean" value="${myProfile.services}"/>
                   <html:select property="societaId" >
                             <html:options collection="myBean" property="idSoc" labelProperty="descrizione" />
                        </html:select>but it still doesn't work.. it says
    Cannot create iterator for [it.object.Services@16b5518, it.object.Services@19fdafc]
    what the way to solve this problem
    thanks
    martina

    <html:select>
    <html:optionsCollection name = "myProfile"
    property = "services" value ="idSoc" label =
    "descrizione"/>
    /html:select>yes evnafets
    you're right
    this code works!
    but there's a problem. To simplify this post I say I've a bean with a Collection inside that I want to iterate.
    In my real application I've a session bean with another bean inside that contains the Collection. I've one more level (3 levels instead 2)
    whit the code you suggest I can't search inside it...
    I mean over myProfile I've onother bean that contains it and it's in the session
    bean1 -> myProfile -> List of Services
    from the session I can take by name only the "bean1"
    do you know what's the solution in this case?
    I've used some code like this
    <bean:define id="myBean" name="bean1" property="profilo"></bean:define>
    <html:select>
            <html:optionsCollection name = "myBean" property = "services" value ="idSoc" label = "descrizione"/>
    </html:select>it works..as you suggest I can specify only attribute names so I think this is the right way... or?!
    thanks a lot for yor help
    martina

  • How to make  struts html:select tag readOnly....!!!!

    Hi All,
    In my below code I want to make <html:select> as readonly like I did for <html:text>
    I don't want to make it disabled as it is graying out that field.
    My requirement is that it should be visible and also it shouldn't be editable.
    I am using Struts...!!!
    <html:text property="paramName" size="20" maxlength="50" readonly="true"/>                                
    <html:select property="paramTypeId" disabled="true"> // I dont want to use this--- disabled="true"
         <html:options collection="queryReturnType" property="value" labelProperty="label"/>
    </html:select>Thanks in advance....!!

    Can some one tell me in the below code
    *1. what is test="${controlEnabled}"....wha is this controlEnabled variable*
    *2. do I need to create an attribute for paramTypeId_Label in my form bean ??*
    I just wanna to make my <html:select> readonly..pls see my first post in this thread....!!
    <c:choose>
         <c:when test="${controlEnabled}">
           <html:select property="paramTypeId" >
                <html:options collection="queryReturnType" property="value" labelProperty="label"/>
           </html:select>
         </c:when>
         <c:otherwise
           <html:text property="paramTypeId_Label" value="${queryReturnType[paramTypeId].label}" readonly="true"/>
           <html:hidden property="paramTypeId"/>
         </c:otherwise>
    </c:choose>--Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for