p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Struts (http://p2p.wrox.com/struts-211/)
-   -   Looping through a list using logic tags problem (http://p2p.wrox.com/struts/40373-looping-through-list-using-logic-tags-problem.html)

aadz5 March 25th, 2006 06:42 PM

Looping through a list using logic tags problem
 
Hiya Guys,

I want to loop through an array list and then display its contents. This is what I have so far:

<logic:iterate id="settings" name="user" property="userSettings">
    <tr>
        <td>Hello baby!</td>
    </tr>
</logic:iterate>

Can someone please help.

Thanks

Adz - Its all about the JSPs baby!

aadz5 March 26th, 2006 09:15 AM

Hiya Guys,

An update to the problem, I now know how to display the value stored in the scripting variable however I wish to do display text fields dynamically with the property value of the string values in the collection. My code is as follows:

<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>

<jsp:useBean id="user" scope="session" class="mnaAccounting.User" />

<html>
<head>
    <title>New Page</title>
    <h1>Test Test Test</h1>
</head>

<body>

<table>
<html:form action="accounting">
    <tr>
        <td><p/>Welcome <bean:write name="user" property="firstName" /> please enter you account details</td>
    </tr>
    <logic:iterate id="settings" name="user" property="userSettings">
    <tr>
        <td><html:text property="<%=(String)settings%>"/></td>
        <td><%=settings%></td>
    </tr>
    </logic:iterate>
    <tr>
        <td><html:submit /></td>
        <td><html:cancel /></td>
    </tr>
</html:form>
</table>

</body>
</html>

I get this error:

exception

javax.servlet.ServletException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
    org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:846)
    org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:779)
    org.apache.jsp.EnterAccounts_jsp._jspService(org.a pache.jsp.EnterAccounts_jsp:157)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:99)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:325)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:295)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:245)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

What am I doing wrong?

Ads

Adz - Its all about the JSPs baby!

aadz5 April 4th, 2006 05:08 PM

Hi People,

I guess no one knows the answer, the problem was in the mapping of the action with the input page, got it sorted though. I have another problem though which I will raise in a second report.

Anyways people Enjoy the struts!



Adz - Its all about the JSPs baby!

suryanarayanjena3 September 23rd, 2011 03:18 AM

Dont wory put ="<%=(String)settings%>" this in ='<%=(String)settings%>'
it will work


All times are GMT -4. The time now is 10:35 PM.

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.