Query on struts html:optionsCollection tag !

Hi,
I've a query on struts <html:optionsCollection tag. I'm trying to render the values of an arraylist using the optionsCollection . The arraylist is stored as a part of form object. But the issue is that each row of arraylist contains a string data. The arraylist is returned by a remote process.Now, when I use the following struts code,
<html:select property="userProxy" size="1" >
<html:optionsCollection property="userProxy" value="" label=""/>
</html:select>
what shud be the value for value and label , as the arraylist contains only one string per row . The userProxy is the arraylist field defined in the form object.
My question, will I be able to use the <html:optionsCollection tag in this scenerio ?
I'll really appreciate if someone can get back to me on this.
Thnx

The html:optionsCollection tag is designed to work with a collection of beans, each with a "label" and "value" attribute.
If you only have a list of strings, then you probably want to use the html:options tag.
Note that your ActionForm should have two attributes
// form bean"
String userProxy;  //stores the currently selected userProxy
List userProxyList;  //list of userProxies.
// assume appropriate get/set methods
// the jsp page:
<html:select property="userProxy" size="1" >
  <html:options property="userProxyList"/>
</html:select>Cheers,
evnafets

Similar Messages

  • How to use form name in struts html:form tag

    Hi,
    I want to validate text box value, if it is ordinary html form I would have done like this <form name="myform" action="xxxx.jsp" onsubmit="return validate()">
    But am using struts html:form tags. In this case how can I use/specify name for a form.
    Can any one help me.
    Thanks

    The name of the form comes from the actionForm you have defined backing it.
    View source on the generated page to see what HTML it constructs.
    You are able to use the onsubmit event with the <html:form> tag just like the standard one, so if all you want to do is that:
    <html:form action="/saveUser" onsubmit="return validate()">
    ...You can also give it a styleId, which will generate an id in the HTML.
    See the tag documentation for details: http://struts.apache.org/1.2.x/userGuide/struts-html.html#form

  • Struts html:text tag background colour

    How to change the background colour of Struts <html:text> tag?

    styleClass and styleId, you can put css value on it

  • Struts html:iterate tag

    Hello all,
    Does anyone know if the struts html:iterate tag can be used to iterate through an ArrayList? Can you populate a html:radio tag with such an iterator?
    If anyone has code examples of these, they would be MOST appreciated!
    Thank you!

    I have an ArrayList object that contains a collection of Listing objects.
    The Listing object has two methods getID, getName
    In the ActionForm there is a variable listingData of List type. How can I use the logic:iterate tag to traverse the ArrayList object and display the id and name of the ListingObjects?
    What has to be added in the logic:iterate tag below?
    <table>
    <logic:iterate id="listingForm" name="listingForm" property="listingData">
    <tr>
    <td>
    // Here I want to output the value of ids
    </td>
    <td>
    // Here I want to output the value of names
    </tr>
    </logic:iterate>
    </table>Do I need a nested logic:iterate tag?
    Should the ArrayList be populated with a J2SE class rather than a business object, i.e. the Listing class?

  • Jsf equivelent of struts html:base tag

    I'm having an issue with the myfaces panelNavigation component. I'm including it in a series of pages with subview & jsp:include tags. It's working great with one exception. If I browse to a document one directory deeper than the "home" page, and then click the "home" link taking me back to the parent directory, the external css sheet doesn't load. All of my links and text are there, but not styled at all. If I click the link again, every thing loads fine.
    I remember the <html:base> tag from struts and I tried using it on the home page. However, the page refused to load and the server did not throw a stack trace (even though the logging is set to FINE).
    I'm wondering if anyone else has experienced a similar issue and if there is an equivelent tag in JSF to solve this problem.
    Thanks!

    thanks for you answer.
    but when i use the <html:base/> tag, everybody can see my internal structure when viewing the source code of the generated html in browser.
    i think i haven't understood the base tag (and have never used it).
    could somebody tell me how to use this tag correctly ? (html or struts version)
    actually my problem is, i used to define a variable at the top of every jsp page like this :
    <%! String conPath ; %>
    <% conPath = request.getContextPath();%>
    then,
    <a href="<%= conPath%>/some/link">Some Text</a> or <img src="<%=conPath%>/image/bottom.jpg">, is there a better way without using java code in jsp ? because when the context root changes some day, i have to change all jsp pages.
    can the <base> tag be helpful here ? how ?
    yawmark,
    when i put all my jsp files under WEB-INF, do i have to change something in struts-config.xml ?
    thanks in advance

  • Unable to Load struts-html-el Tags

    Hello, I downloaded the struts-html-el-1.2.8.tld and dropped it in my Elipse workspace under the WebContent/WEB-INF/tld directory where other struts-html.tld, struts-logic.tld, etc. are.
    In my JSP, I have
    <%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html-el"%>where http://struts.apache.org/tags-html-el is what is given in the struts-html-el-1.2.8.tld.
    Then, I used <html-el:form ...> <html-el:checkbox ...> <html-el:hidden ...> in my JSP. But, I got runtime error: "Unable to load tag handler class org.apache.strutsel.taglib.html.ELFormTag"
    What should I do?

    Where do I find the JAR for the html-el? I could not find it from the Struts framework download.
    What is the URL for tht JAR? Thanks in advance.

  • How to use bean write in  struts html:text tag

    hi,
    i'm new to struts concepts.here i'm trying to write a value in html struts tag using <bean:write>
    my current tag is
    <html:text property="empname" value='<bean:write name="employee" property="empid">' />
    but it gives same tag in the text box.how i can solve this.

    what am I doing wrong?You will notice above that I mentioned
    YOU CAN'T USE CUSTOM TAGS AS ATTRIBUTES TO OTHER CUSTOM TAGS
    (was that loud enough for you to notice this time)?
    Try
    <html:text styleId="instruction" styleClass="text" size="50" name="instruction" property="value"/>
    //or
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction" value="<%= instruction.getValue() %>"/>
    better alternative: populate your formbean with your action and just have:
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction"/>
    If you set the "instruction" property of your formBean in the action, the value will be automagically reflected here.
    Cheers,
    evnafets

  • Struts - HTML:link tag with dynamic page attribute?

    I am trying to use the html:link but the page value is dynamic (resulting from the bean within the iterate tag). The code below doesn't work - error. Is there a way to use all Struts tags and make this happen. Any ideas?
            <logic:iterate id="myMenuForm" property="menuItem" scope="session" name="menuForm" >          <html:link page="<bean:write name="myMenuForm" property="menuDisplayName"/>">                  <bean:write name="myMenuForm" property="menuDisplayName"/>          </html:link>        </logic:iterate> Thanks,
    mlv

    Thanks for all your help. Based on all you your comments, it is now working
    and I thought I would provide some details about how I got it working.
    There are not that many examples within the Struts documentation.
    id = unique name for the object that can be referenced within the iterate
    tag.
    name = is the Bean, in this case it's the ActionForm, that contains the List
    object that will be iterated. In my case, I have a ActionForm that contains
    a List property that contains all the menu item rows from the databse.
    property = is the property name within the ActionForm that is the List
    object. Links to the getter method
    Within the <bean:write> tag you use the id name to get a handle on the final
    object from the iterate tag and the property is one of the property values
    within the bean that is contained within the List.
    So in this case I have a ActionForm bean that contains a List property that
    contains a collection of beans.
    FormAction - bean
    property menuItems of type List contains:
    - row 1 = bean (with a property of menuDisplayName)
    - row 2 = bean (with a property of menuDisplayName)
    - row 3 = bean (with a property of menuDisplayName)
    Here's the JSP code for the tag.
            <logic:iterate id="myMenuForm" name="menuForm" property="menuItem" >
              <html:link page="www.yahoo.com"/>
                      <bean:write name="myMenuForm" property="menuDisplayName"/>
              </html:link>
            </logic:iterate>Now I would like to make the <html:link> page attribute value dynamic from
    the iterate bean. Therefore, you can make the url for the link dynamic If
    you know how to do that, please feel free to provide some help.

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Struts html:select tag

    Hi All,
    I am using struts. I want a dropdown single select menu option on my Jsp page.
    Basically, the options would be a dropdown either US or CA (meaning USA or CANADA). Html selectoptions is easy. How to do it in struts ?
    Once page is displayed, US will be selected by default. Then user may select either of the value from dropdown.
    Then, I have a state option dropdown, which should get populated, depending upon the first selection. Meaning, if user selects US in first dropdown, then all USA states show up in this second single select options.
    If user selects CA in first dropdown, then CANADA states show up in this second dropdown. I have the states list with me for both US and Canada.
    Can anyone send me a snippet of code for first dropdown. and then how in struts can I populate the second single select states dropdown (depending on whether user selected US or CA in first dropdown)
    Any help highly appreciated.
    thanks,
    pp

    Thanks Shanu.
    Nope. I am populating states in both cases in the ActionForm constructor. in other words, they are not coming from database. Folowing is short snippet how I am populating. So, I am able to display those states on the Jsp page dropdown.
    Onlything, i am stuck at is "that determination switch" as I quoted in previous post like
    If (US) then showUsStates else show CanadaStates on the Jsp thinggy ......... I am stuck here.
    And it has to happen on client side, cause if I sybmit the form, its gonna complain about other mandatory textfields like city , zip , phone NOT found as a result of Submit to ActionForm validation -- Even when user has yet to input rest of values and submit the entire form. Thats the reason why I say "On selection of country dropdown, population of appropriate states has to happen on client side"
    Any idea ?
      public CreateServiceRequestForm() {
             countrybean = new CountryBean[2];
             for (int i = 0; i < 2; i++) {
                 countrybean[i] = new CountryBean();
                 countrybean.setCountry(i);
    countrybean[0].setCountryName("US");
    countrybean[1].setCountryName("CA");
    statebean = new StateBean[54];
    for (int i = 0; i < 54; i++) {
    statebean[i] = new StateBean();
    statebean[i].setStateId(i);
    statebean[0].setName("AK");
    statebean[1].setName("AL");
    statebean[2].setName("AR");
    statebean[3].setName("AZ");
    statebean[4].setName("CA");                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Struts html:file tag problem

    Hi,
    I have already posted but couldn't get the solution. So just incase if anyone can suggest something, it would be appreciated.
    On the form, there is a browse button and a submit button. The normal procedure of clicking on the browse button, and then submit button using mouse works fine. But what we want is , When mouse is pointed on browse button and a "ENTER" button is clicked on keyboard, the file browse window pops up . When we click submit button, that file should be submitted and get processed. The problem is when mouse is pointed on browse button and a "ENTER" button is clicked on keyboard, the file browse window pops up and then when I click submit button, the text field is cleared off instead of being processed.
    I tried all sorts of javascript but still don't know why the text is erased once the submit button is clicked.
    Any suggestions??
    The code related to this is:
    function focus1() {
    if(document.all.uploadFile.click())
    return true ;
    else
    return false ;
    <html:form method="post" action="/SubmitTrans.do" enctype="multipart/form-data" focus="uploadFile">
    Choose the file
    <b>Select File</b> <html:file property="uploadFile" onfiltered=' return focus1();'/>
    <html:submit value="Process"/>
    </html:form>
    Thanks in advance.

    Because the bean util is using reflection to lookup the methods for getting and setting the value. Thus it can't find getter and setter methods for the member named File. But if the member is named file, then it finds getFile() and setFile() because they follow the naming convention. If your not familiar with reflection and java beans, you should take a look at some brief tutorial.
    Example:
    private String username;
    public String getUsername() {
       return username;
    public void setUsername(String name) {
         username = name;
    }

  • Action listener for struts html tag

    hi i am doing a project using sturts. I have used struts HTML Select tag with a collection of values in select box. now i want to write an actionlistner for that select...ie if i select any value from the select list it should do some action like take me to different page...can anyone tell me how can i do that...
    Thanks

    Soultech, I think you're being a bit harsh. Struts is a valid topic on this forum as it is a java framework related to JSP.
    However having said that, the question does show a basic misunderstanding of JSP technology.
    JSP = Java SERVER Pages. Java code only runs on the server.
    All that gets sent to the client (browser) is an HTML file.
    You can not write java action listeners to run and respond to events on the client.
    For any client side interaction you will have to use javascript (which is NOT java) - probably an onclick/onchange event - the same as any other web page.
    However you can only run javascript code from such events.
    To run java again you have to submit a request to a server - normally done by submitting a form.

  • ADF/Struts Generated tag code variations? Struts html:text vs Html input

    Hi,
    JDev 10.1.2.1
    ADF/Struts
    I noticed that the JDev IDE generates different code for a same component/binding combination.
    Example:Data Control of type Input form with same VO selection.
    Generated code for 1 field:
    case 1)
    JSP code:
    <tr>
    <td>
    <c:out value="${bindings['TitleLang1'].label}"/>
    </td>
    <td>
    <html:text property="TitleLang1"/>
    </td>
    </tr>
    HTML output:
    <tr>
    <td>
    Short Title Language 1
    </td>
    <td>
    <input type="text" name="TitleLang1" value="Preliminary Demo">
    </td>
    </tr>
    case 2)
    JSP code:
    <tr>
    <td>
    <c:out value="${bindings['TitleLang1'].label}"/>
    </td>
    <td>
    <input type="text" name="<c:out value='${bindings.TitleLang1.path}'/>" value="<c:out value='${bindings.TitleLang1}'/>"/>
    </td>
    </tr>
    HTML output:
    <tr>
    <td>
    Short Title Language 1
    </td>
    <td>
    <input type="text" name="VB_TitleLang1" value="Preliminary Demo"/>
    </td>
    </tr>
    Case 1 generated code is obvious to me, the html name of the field equals the field binding id.
    In Case 2, the VB_ prefix is added and the binding variable references bindings.fieldName.path?
    Could someone explain me the second flavor?
    When should we use the path reference and replace the Struts html:text tag with html input tag?
    Thanks
    Fred

    I dont think you can mix static values and rt expressions together in attribute values.
    String onBlurString = "dontLeaveItEmpty(this);referenceEntered(" + recordNumber + ")" ;
    html:text styleClass="textFieldInTable" name="refrences" property="referenceName" onblur="<%=onBlurString%>" />cheers,
    ram.

  • Html:select tag

    Hi all,
    In my jsp page i am using struts html:select tag,some contents are not fitting in the alloted size so i want to give horizontal scrolling for this select box,pls any body can tell me which property of select tag can be used,or any html tricks by which i can achive horizontal scrolling.examples will be help full.
    thanks,

    There aren't any tricks. This has nothing to do with Struts or JSP. It only has to to with HTML. The width is controlled by the size of the options or the size of the HTML area it has to display in. The latter if it's restricted otherwise by some table cell's width. I don't believe that I've ever seen a select box which has horizontol scrolling in any browser ever.

  • How to use pdk-struts-html:link

    i have a portlet,
         <pdk-html:link href="/StartEhrpHrj.do?targetGroup=Hrj1030MInfDtlGroup">
                   xyz
    </pdk-html:link> </td>
    but no link,why

    Hi,
    It is not an issue with the tag. Look at the docs for the struts html:link tag; the pdk-html:link tag is intended to replace this tag and not the regular HTML anchor tag.
    Good luck,
    Hernando
    hjbconsulting at comcast dot net

Maybe you are looking for

  • Letter of credit release with VXA3

    Hello,   I have this scenario: - Created a Letter of Credit with 100.000 EUR of amount; - Assigned the letter of Credit to a Sales Order of 250.000 EUR of amount --> the Sales Order is blocked from credit control because the value of the Financial Do

  • Timer task (Time Schduling ) in JSP for hit/browse another site page

    Hi All , I want to develope a JSP application which is run the perticular link in every 30 min. means i want to set the scheduling of 30 min which is browese(run) my another server link like http://nileshpatel.com/abc.jsp How can i do it OR Time Sche

  • Can I use IPhone 5s of Hong Kong in India??

    i live in india and I have purchased a iPhone 5s of hong kong and want use it in india can i use it??????

  • OIM 11g Entity Adapters

    Hi all, I have developed an Entity Adapter using Oracle Identity Manager Design Console which generates different account user ids against a user defined field on Process Form. Here I'll provide more details about my scenario. SCENARIO* a. OIM versio

  • Daily disconnects and Like the Oscars not very ori...

    Hi Wonder if you guys could shed light on an issue on an issue I am currently having. Are you seated comfortably then I shall begin. Received an email beginning of December last year about exchange being upgraded and since then nothing but problems