Problem in html:select

MY problem is
my html:select
<html:select property = "planetID" size = "1">
<html:option value = "1">one</html:option>
<html:option value = "2">two</html:option>
<html:option value = "3">three</html:option>
<html:option value = "4">four</html:option>
</html:select>
when user vist this page i want[b] three to be selected in html:select
i have tried using
<html:option value = "3" selected>three</html:option> but it is not working
please help me this is urgent

If you want to select an option by default, you should specify it in the struts-config.xml int the form bean.
<form-property name="month"  initial="0"   type="java.lang.String" />

Similar Messages

  • 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 with html:select field

    I have two forms A and B, which I open from A. In B I have an <html:select property="X" and in A I have <html:text property="Y". In the javascript in B, I am trying to assign the document.B.Y.value as follows:
    opener.document.A.X.value = document.B.Y.value;
    On closing B, I do not see any values in A.X.
    Please help as to how I could make the value display in A.X?
    Thank you!

    Hi,
    I'm not sure if I understood your question! Do You want access form variables of A from form B, using the JavaScript? That is it??
    If I understood right, you need use a funcion called getElementById, it's a only way that I know.
    I hope it be useful

  • I have a problem in html:select option

    I need to retrieve the value from the dropdown list of html:select from the formbean .
    As of now its populated with hardcoded values
    Anyhelp appreciated

    I made the changes to the jsp file ...but this time its throwing the following error.
    help me ..
    javax.servlet.jsp.JspException: No getter method available for property selectedCounty for bean under name org.apache.struts.taglib.html.BEAN
         at org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:327)
         at org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:244)
         at jsp_servlet.__contract._jspService(__contract.java:245)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:322)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6718)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

  • 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.

  • 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

  • Problem in multiple selections in a jList

    I have two jLists. Now I have to select some items from one jlist and have to transfer in the other one. But while trying to do it in the runtime I am getting some unexpected runtime errors including "Exception occurred during event dispatching". When I try to transfer only one item it works fine but shows problem in multiple selections. Pleast give your suggestions.

    [_First suggestion_|http://catb.org/~esr/faqs/smart-questions.html]
    [_Second suggestion_|http://mindprod.com/jgloss/sscce.html]
    db

  • 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

  • Html:select onchange

    Hi,
    In html:select tag, i'm using onchange function to submit the page. The problem here is, after selecting a value, if I immediately select another from the combo,it again submits but the page renders with blank page. is there is anyother way to solve this??
    thanks in advance.

    yeah, don't do that.
    You can force not doing that by doing this:
    ... onchange="theSubmitThing(); this.disabled = true;" ...

  • 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...

  • html:select and html:options simple question  - please help

    Hi Friends,
    I am having a problem, please help me .I want to run a query and display all the lastnames of all the users in my database.Here are my files:
    UserForm.java
    public class UserForm extends ActionForm{
         private name firstName;
         private name lastName;
         //all getter and setters
    viewuser.jsp
    <html:select property="lastName">
        <html:options collection="users" property="lastName" labelProperty="lastName" />
    </html:select>
    and my Java Utility class method
    public ArrayList getusers() throws Exception {
             ArrayList aList = new ArrayList();     
              Connection con = ConnectionUtil.getConnection();
              PreparedStatement stmt = null;
              try {
                   stmt = con.prepareStatement("select last_name from USERS);     
                   ResultSet rs = stmt.executeQuery();
                      if (rs.next()) {
                          aList.add(rs.getString(1));
                      }else {
                           return null;
                      rs.close();
                      return aList;
              } catch (SQLException e) {
                   e.printStackTrace();
                   throw new ServiceProcessingException(e.getMessage());
              } finally {
                   ConnectionUtil.closeStatement(stmt);
                   ConnectionUtil.closeConnection(con);
         }My problem is what i need to do in my Action class,so that it sets the "users" variable
    properly and i would be able to read that variable in my jsp and display the lastname
    of all the users.I am tryin this but failing badly:
    public class UserAction extends Action{
      ArrayList userssList = Utility_class_obj.getUsers();
      request.getSession().getServletContext().setAttribute("users", usersList);Please Please help,I would really appreciate your help.
    Thanks

    Thanks a lot friend...this time i made it work my style,next time i will use tha mehod.But I think I am not doing it the right way,please correct me:
    This is the method in my utility class where i run the query and I doubt I am not doing it right here:
    PreparedStatement stmt = null;
    ViewForm vForm = null;
    try {
    stmt = con.prepareStatement("SELECT LAST_NAME FROM   USERS_ADD");     \
    ResultSet rs = stmt.executeQuery();          
    while(rs.next()) {
           vForm = new ViewForm(rs.getString(1));          
          aList.add(vForm);          
       rs.close();
       return aList;          }
    }And I made this constructor in my viewForm class:
    public ViewForm(String lastName){          this.setLastName(lastName);     }I do this in my Action class then:
    ArrayList pList = csDAO.getUsers();  
         if(pList  != null){         
         request.getSession().getServletContext().setAttribute("plist", pList);      
    }And finally this in my jsp:
        <html:select property="lastName"> 
        <html: options collection="plist" property="lastName" labelProperty="lastName" /> And it works,but i don't think I can keep adding constructors to my form class like that,and moreoever if I want to search by first name ,there would be a conflict between 2 constructors,so can someone please tell me the right way to do this.
    Thanks
    Mick

  • Pls help me.....problem with html:optin in struts.

    hi all,
    i need to get the selected value from the option element.how can i get it?
    what is the type expresiion in tha value field.....
    this code is not working at all. i am getting the entire string inside the quotes...as selected value...what i want...is vale of that expression in quotes...
    ="<bean:write name="currency" property="key"/>"//// anyone knoe?
    <html:select name="currency"
    property="currencyCode">
    <logic:iterate id="currency" name="currencyList">           
    <html:option value="<bean:write name="currency" property="key"/>"><bean:write name="currency" property="key"/> <SELECTED></html:option>     
    </logic:iterate>     </html:select>

    It would be better answered on a JSP forum. :-)

  • The html select box option is not getting displayed properly in IE11

    The html select box option is not getting displayed properly in IE11
    I have developed a website that has a select box drop down. The select box drop down is getting displayed properly in IE9. But in IE11, if I am selecting any option apart from the first one, the whole select box option is getting moved up in the page.
    In IE11, if option 2 is selected, then the select options is getting moved up. But in IE9, if option 2 is selected, then the select options is getting displayed properly.
    Please let me know the fix so that the select options are displayed in the same manner as in IE9.
    Sorry but I am unable to upload images as this site is throwing some error

    Hi Kevin Shen,
    Thanks for post.
    I tried above code in ie 11(version 11.0.9600.17633).
    But it is not working. If you select option 2, and open select box then it open on the select box.
    It should open below the select box.
    Code for above:-
    <select>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    </select>
    Sorry I could not attach screen shot. We have normal select box with three options. If we select option 2, it is showing option list on the select box. It is coming below the select box in ie 10 and other browse like chrome. 
    So what we should do, so that all options will come below the select box?
    Thanks,
    Yogesh Toke

  • 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

  • Problem in getting selected values from multiselect list

    Hi,
    I have two multiselect listboxes in my page. In List1 the data will be retrieved from DB and listed.I will have buttons to move the values from List1 to List2 and viceversa.
    After selecting the needed values,I can rearrange them in List2 using some buttons. I have coded this moving and reordering using javascript.
    What happens is while submitting the page I want the values from list2 which are rearranged. But im getting the order in which I moved from list1 to list2.
    I am using html:selectfor both lists
    List1
    <html:select name="CustForm" property="custName" multiple="true" size="10">
           <html optionsCollection property="CustomerNames" value="custName" label="id"/>
    </html:select>I am having a customer form which has a arraylist CustomerNames. This arraylist has customer bean which has proeprties custName and id. The custForm also has a String custName.
    List2
    <html:select name="CustForm" property="selectedCustName" multiple="true" size="10">
           <html  option value=""/>
    </html:select> The custForm also has a String[] selectedCustNames from where I get the selected values in list2
    Please let me know what am I doing wrong here.

    use a treeSelectionListener, that will give you all the selection changes you need.
    thomas

Maybe you are looking for