java - using an attribute of an arraylist in my jsp with struts-bean.tld -
java - using an attribute of an arraylist in my jsp with struts-bean.tld -
i have issue using attribute of arraylist in jsp. arraylist in actionform :
private arraylist<account> accounts = new arraylist<account>();
the class declaration of business relationship object in arraylist :
public class business relationship implements serializable, cloneable { private string bic; public string getbic() { homecoming bic; } public void setbic(final string newbic) { bic = newbic; } }
the phone call in jsp :
<bean:write name="bankaccountsactionform" property="accounts.get(0).bic" />
the console error :
javax.servlet.jsp.jspexception: no getter method property accounts.get(0).bic of bean bankaccountsactionform
do have solution or way this?
i have terrible alternative using property accountbic1 straight in form. induces lots of work behind re impact temporary attributes real arraylist
.
if have collection of items in struts 1.x, utilize <logic:iterate>
tag.
add struts-logic.tld
taglig on top of jsp follows:
<%@ taglib uri="/web-inf/struts-logic.tld" prefix="logic"%>
then, using <logic:present>
, <logic:iterate>
can iterate arraylist
follows:
<logic:present name="accounts"> <logic:iterate id="account" name="accounts"> <bean:write name="account.bic" /> </logic:iterate> </logic:present>
if want iterate collection , access particular index, utilize indexid
on <logic:iterate>
so:
<logic:present name="accounts"> <logic:iterate id="account" name="accounts" indexid="index"> <logic:equal name="index" value="0"> <bean:write name="account.bic" /> </logic:equal> </logic:iterate> </logic:present>
the same can done using jstl:
<logic:present name="accounts"> <logic:iterate id="account" name="accounts" indexid="index"> <c:if test="${index == 0}"> <bean:write name="account.bic" /> </c:if> </logic:iterate> </logic:present>
make sure account
class has getter/setter method attribute bic
.
java struts-1 taglib
Comments
Post a Comment