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.

Similar Messages

  • 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

  • Having problems passing more than one parameter with html:link tag

    Hi guys,
    for my web application I�m using Struts. I�ve got a database with user details. I would like to get users list and link to the details of each user. I wrote the code and everything is working fine only the users list is repeating as many times as users in the list.
    For ex: I have in the database User1, User2 and User3. I would like to have a result like:
    User1
    User2
    User3
    Instead of it I have the result like:
    User1
    User2
    User3
    User1
    User2
    User3
    User1
    User2
    User3
    What I�m doing wrong? Could somebody help me please?
    Thank you in advance
    There is a snippet of the code, which I�m using in jsp:
    <code>
    <logic:iterate id="root" name="user">               
                   <%
                        java.util.HashMap users = new java.util.HashMap();
                        params.put("user",root);
                        pageContext.setAttribute("usersName", users);
                   %>
                   <html:link name=" usersName " scope="page" page="/name.do">
                        <logic:iterate id="folder" name="user">
                             <bean:write name="folder" /><br>
                        </logic:iterate>
                   </html:link><br>
                   </logic:iterate>
    </code>

    Suggestion: next time you post code use the "CODE" button to put code tags around it. It formats much nicer that way :-)
    You have a nested loop structure here.
    <logic:iterate id="root" name="user">
      <%
        java.util.HashMap users = new java.util.HashMap();
        params.put("user",root);
        pageContext.setAttribute("usersName", users);
      %>
      <html:link name=" usersName " scope="page" page="/name.do">
        <logic:iterate id="folder" name="user">
          <bean:write name="folder" /><br>
        </logic:iterate>
      </html:link><br>
    </logic:iterate>Both loops iterate over your "user".
    Your first loop loops over each user.
    Then your second loop also loops over each user - hence you get number of users * number of users = 3 groups of 3.
    If you have 4 users, you would have 4 groups of 4.
    I only see you setting one parameter: "usersName" What other parameters do you need to pass?
    At a guess, the inner loop is unnecessary, and you want to write the users name as the text for the link, and also use it as a link parameter.
    <logic:iterate id="root" name="user">
      <%
        java.util.HashMap users = new java.util.HashMap();
        params.put("user",root);
        pageContext.setAttribute("usersName", users);
      %>
      <html:link name="usersName" scope="page" page="/name.do">
          <bean:write name="user" /><br>
      </html:link><br>
    </logic:iterate>

  • Problem in html:link tag in struts

    hi every body i have a problem i have to pass two dynamic variable to next page using html:link tag how can i send it
    for example
    <a href = "editEmp.jsp?id=<%= empSno %>&&delete=no"> Edit </a>
    should be coverted into <html:link >and i want to pass 2 parameters to next page how can i do can anybody help

    i have used forward only but how to passs variable dynamically in forward for eaxmpleeee
    i am retreving records from database
    emdID name desig
    1 suresh PM edit
    2 ram PL edit
    when user clecks on link of edit of suresh then i should pass controll to edit page with his empID an parameter............
    i have done this prevoiusly by href tag like
    while (rst.next()) { %>
                        <tr>
                             <% empSno = rst.getInt ("ID");%>
                             <td align = "left"><%= empSno %></td>
                             <td align = "left"><%= rst.getString ("empno") %></td>
                             <td align = "left"><%= rst.getString ("empname") %></td>
                             <td align = "left"><%= rst.getString ("desig") %></td>
                             <td><a href = "strutsEx/ch05/editEmp.jsp?id=<%= empSno %>&&delete=no"> Edit </a>&nbsp&nbsp&nbsp&nbsp<a href = "editEmp.jsp?id=<%= empSno %>&&delete=yes"> Delete </a>
                             </td>
                        </tr>
    now i want to use html:link action in place of HREF can u help me plzzzzzzzzzz

  • 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

  • Help on oracle tags inside dynamic pages

    Hi All
    I have used dynamic pages like this , i create a html form inside a dynamic page on submit of which a procedure gets called & inserts the values in the table.
    I see some <oracle> tags every time i create a dynamic page but have never used them. Could some one tell how to use these tags. whether they can be used to call a procedure or can i embed any dml statements in these oracle tags.
    Kindly somebody could explain it with an example.
    Regards
    Sushant

    There is a brief description in the online help - see http://isd-demos2.oracle.com:7778/help/wvtdynam.htm.
    You can also search this forum - there have been many examples posted here.
    If you have further questions about dynamic pages, the Portal Applications forum would be a better place to post them.
    Regards,
    Jerry
    Portal PM

  • Help on oracle tags in dynamic pages

    Hi All
    I have used dynamic pages like this , i create a html form inside a dynamic page on submit of which a procedure gets called & inserts the values in the table.
    I see some <oracle> tags every time i create a dynamic page but have never used them. Could some one tell how to use these tags. whether they can be used to call a procedure or can i embed any dml statements in these oracle tags.
    Kindly somebody could explain it with an example.
    Regards
    Sushant

    Hi,
    You can do all that you can do in a plsql block.
    Here is an example which paints a form for the employee records and submits them. On submit a procedure submit_form is called.
    <HTML>
    <HEAD>
    <TITLE>Example</TITLE>
    </HEAD>
    <BODY>
    <FORM action="<schema name>.submit_form" method="post">
    <H2>Example of A Dynamic Page</H2>
    <ORACLE>
    begin
    for c1 in (select * from scott.emp )
    loop
         htp.p(c1.empno);
         htp.p(c1.ename);
         htp.p(c1.deptno);
         htp.p(c1.hiredate);
         htp.p(c1.sal);
         htp.p('<input type="hidden" name="p_empno" value='||c1.empno||'>');
         htp.p('<input type="text" name="p_comm">');
         htp.p('<br>');
    end loop;
    htp.p('<input type="submit" name="p_action">');
    end;
    </ORACLE>
    </BODY>
    </FORM>
    </HTML>
    Thanks,
    Sharmila

  • Is it possible to call on a link in a dynamic page?

    I have created a dynamic page with sql code in it. When I go to customation form, for the page I just created, there is a button called run dynamic page. When I click this the sql code on the page execute. I can also make a link to the customation form so when I run this link the page with button run dynamic page appear. The question is if there is someway you can use this link in another dynamic page you just created so you get a page with the button run dynamic page when you run the page? Or is there another solution to the problem to get a page with a button to run sql code?

    Hi,
    You can call a component's customization form in the dynamic page like this
    <HTML>
    <HEAD>
    <TITLE>Example</TITLE>
    </HEAD>
    <BODY>
    <H2>Example of A Dynamic Page</H2>
    <ORACLE>
    begin
    SJAYARAM903_1G.RPT_0911010900.show_parms;
    end;
    </ORACLE>
    </BODY>
    This would render the customization form in the dynamic page.
    Thanks,
    Sharmila

  • 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: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?

  • Regular Expression to convert URI to HTML link tag

    I'm trying to create a method that takes an input string and converts any URIs found in the string to a html link tag.
    For example,
    String input = "This is a test string.  I like http://www.sun.com/ and think you should check out http://java.sun.com/"; The output should contain an html a tag for each URI and use the URI as the text as well.
    I need this for a blogging web app i'm working on.
    I tried a few things like
    import java.util.regex.*;
    import java.text.*;
    public class test
         public static void main(String[] args)
              final Pattern p = Pattern.compile("(\\sI\\n|^)(\\w+://[^\\s\\n]+)");
            final Matcher m = p.matcher(args[0]);
              System.out.println(args[0]);
              args[0] = m.replaceAll( "$1<a href=\"$2\">$2</a>");
              System.out.println(args[0]);
    }Any ideas? Something like this will match "http://www.apple.com/" but not a complex string. I've googled this quite a bit and I'm not very good with regular expressions.

    Couldn't get your posted regex to work on anything. Try this:public static void main(String[] args) {
        String input = "This is a test string.  I like http://www.sun.com/ and think you should check out http://java.sun.com/";
        final Pattern p = Pattern.compile("(\\s|^)(\\w+://\\S+)(\\s|$)");
        final Matcher m = p.matcher(input);
        input = m.replaceAll("$1<a href=\"$2\">$2</a>$3");
        System.out.println(input);
    }It should match any uri, however I recommend replacing \\w+ with a more concrete string like (?:(?:http)|(?:https)|(?:ftp)). Let me know if you have a uri that it doesn't match.

  • Cannot find procedures with dynamic pages

    Hi all,
    I have a problem with dynamic pages. cannot find procedures.
    This is the content of a a dynamic page (example):
    <HTML>
    <ORACLE>
    begin
    htp.print(htf.bold(‘Fill in field values and use the push button to buy ticket’));
    htp.br;
    htp.formOpen(‘NETU.BUY_TICKETS’);
    htp.teletype(‘Student Id___:’);
    htp.formText(‘p_id’,5,5);
    htp.br;
    htp.teletype(‘Event Id_____:’);
    htp.formText(‘p_eventid’,5,5);
    htp.br;
    htp.teletype(‘# of Tickets_:’);
    htp.formText(‘p_no_of_tickets’,5,5);
    htp.br;
    htp.teletype(‘Credit Card’);
    htp.br;
    htp.teletype(‘AMEX,MC,VISA_:’);
    htp.formText(‘p_cc_type’,5,5);
    htp.br;
    htp.teletype(‘Card #_______:’);
    htp.formText(‘p_cc_number’,10,10);
    htp.br;
    htp.formSubmit(NULL,’Buy Ticket’);
    htp.formClose;
    end;
    </ORACLE>
    <HTML>
    and try to call to this procedure ‘NETU.BUY_TICKETS’ for save form data in BD:
    begin
    insert into tickets (id, eventid, no_of_tickets,cc_type,cc_number, trans_date) values (p_id, p_eventid, p_no_of_tickets, p_cc_type, p_cc_number, sysdate);
    exception when others then htp.print(‘SQL Error Message:’||substr(SQLERRM,1, 200));
    end;
    All compiled fine.
    The problem exact is when i submit the form, cannot find procedure.
    In browser address show this -> http://portal:7778/pls/portal/NETU.BUY_TICKETS
    and in the body...
    404 Not Found
    Unable to process request. Please check the log file for more details.
    The dev is on OracleAS 10g, on a Solaris 5.10 dual Sparc machine.
    With:
         HTTP_Server     
         Internet Directory
         OC4J_SECURITY     
         Single Sign-On:orasso     
         Gestión
    on infra tier and
         Discoverer     
         Forms     
         home     
         HTTP_Server     
         OC4J_BI_Forms     
         OC4J_Portal     
         OC4J_Wireless     
         Portal:portal     
         Reports Server: rep_portal_oracleas2     
         Web Cache     
         Wireless     
         Gestión     
    on middle tier, all running without problem...
    mmm ... what's wrong? where is the log? i find a lot...

    I have tried your code and it works for me . Here are the steps and codes I have used to stimulate your process
    1. Created the procedure
    CREATE OR REPLACE PROCEDURE p_buy_tickets (p_id in number, p_eventid in number, p_no_of_tickets in number, p_cc_type in varchar2, p_cc_number in number) IS
    BEGIN
    htp.print('Processed Successfully');
    EXCEPTION
    WHEN OTHERS THEN
    htp.print('SQL Error Message:'||substr(SQLERRM,1, 200));
    END p_buy_tickets;
    2. Granted 'Execute' privilge on this procedure to Public.
    3. Created a dynamic page with the following code (same as yours except the schema):
    <HTML>
    <ORACLE>begin
    htp.print(htf.bold('Fill in field values and use the push button to buy ticket'));
    htp.br;
    htp.formOpen('MY_SCHEMA.P_BUY_TICKETS');
    htp.teletype('Student Id___:');
    htp.formText('p_id',5,5);
    htp.br;
    htp.teletype('Event Id_____:');
    htp.formText('p_eventid',5,5);
    htp.br;
    htp.teletype('# of Tickets_:');
    htp.formText('p_no_of_tickets',5,5);
    htp.br;
    htp.teletype('Credit Card');
    htp.br;
    htp.teletype('AMEX,MC,VISA_:');
    htp.formText('p_cc_type',5,5);
    htp.br;
    htp.teletype('Card #_______:');
    htp.formText('p_cc_number',10,10);
    htp.br;
    htp.formSubmit(NULL,'Buy Ticket');
    htp.formClose;
    end;
    </ORACLE>
    <HTML>
    4. I got the message 'Processed Successfully' when I ran the dynamic page and submitted the form.
    You may need to check how you declared parameters in the procedure and how you supplied values when you run the procedure. In this case, I created the procedure with "No Default" value for all parameters , so I have to supply value for all parameters in the form otherwise I will encounter the 'Page Not Found' error.
    Hope this helps!.
    Thanks
    Krishnamurthy

  • 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

  • html:link problem with Mozilla vs. IE

    Hello,
    I am experiencing the following situation.
    In IE the following segment of code works properly:
    <td>
    <table border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
         <html-el:link action="zone3/g036Play">
         <td><html-el:img srcKey="detailsLeft2" bundle="ZONE3_IMAGE_RESOURCE_KEY" border="0" width="17" height="18"/></td>
         <td class="details"><bean-el:message key="couponsHistory.details" bundle="XLTS_MESSAGE_RESOURCE_KEY"/></td>
         <td><html-el:img srcKey="detailsRight2" bundle="ZONE3_IMAGE_RESOURCE_KEY" border="0" width="9" height="18"/></td>
         </html-el:link>
    </tr>
    </table>
    </td>BUT in Mozilla the link doesn't work
    On the other hand, i found out that if i place the <html:link> tag outside of the table, then the link will work properly for mozilla but won't work for IE.
    Is there a way i can work this problem around?
    Thank you very much in advance.
    Frini

    ok, sorry, my mistake, i was looking at the wrong fragment of code.
    It output the HTML code:
       <td><a href="/XltsWeb/zone3/g036Play.web"><img src="images/xlts/details_left_lottery.gif" height="18" width="17" border="0"></td>
       <td class="details">Details</td>
       <td><img src="images/xlts/details_right1_lottery.gif" height="18" width="9" border="0"></a></td>which still doesn't work in Mozilla as a link...
    But if i place <html:link> outside the table and inside TD, i get:
    <td>
      <a href="/XltsWeb/zone3/g036Play.web"><table border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <td>
       <td><img src="images/xlts/details_left2_lottery.gif" height="18" width="17" border="0"></td>
       <td class="details">Details</td>
       <td><img src="images/xlts/details_right2_lottery.gif" height="18" width="9" border="0"></td>
       </td>
       </tr>
       </table></a>
    </td>and works in Mozilla, BUT no, none of the above works in IE!!!!!!!!!!!!!!!!!!!!!
    The only code that works in IE, is the first that i posted!!!!

  • Passing values to action form in struts using html:link tag in struts

    hi
    As we can post values to action form bean in struts using a <html:text> tag in side a form.
    Can the same be achieved by using a html:link attribute.
    If not then how can this be achieved (i.e. posting a form on click of a link and populating action form bean property for the same).
    thanx in advance.

    Crosspost:
    http://forum.java.sun.com/thread.jspa?threadID=5244035&tstart=0

Maybe you are looking for