aspose file tools*
The moose likes Struts and the fly likes logic:iterate not bean found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:iterate not bean found " Watch "logic:iterate not bean found " New topic
Author

logic:iterate not bean found

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

Why i get Cannot find bean roles in any scope


My action
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

String cmd = "success";

TablaModel tablaModel = new TablaModel();
List listaRoles= tablaModel.getElements("st_roles");
request.setAttribute("roles", listaRoles);
return mapping.findForward(cmd);
}
Type inside list, with get set methods

private String tabla;
private int id;
private String idVarchar;
private String idVarcharAnt;
private String nombre;

public TablaDto(String tabla){
this.tabla = tabla;
}
public TablaDto(){

}
public TablaDto(int id, String nombre){
this.id = id;
this.nombre = nombre;
}


My jsp
<logic:iterate name="roles" id="rol">
<td width="20"><input type="checkbox" name="checkbox" value="checkbox"></td>
<td width="55"><strong><c ut value="${rol.nombre}"/> </strong></td>
</logic:iterate>
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Here's a guess as to what might be happening: If the Action class you showed us is specified in the action attribute of the <html:form> tag in the JSP that is being displayed, The action is not getting called until the form has already been submitted, so it can't possibly populate the list before the JSP gets displayed. Hence, the JSP can't find the list.

In a case like this, you need two actions: one to prepare to display the JSP, and another to process the JSP once it has been submitted. The logic you've shown us should go in the preparatory action, not the processing action. In the case of the preparatory action, you should call the action URI directly (e.g. myAction.do) and have it forward to the JSP you're showing us.

I may be totally wrong in my guess, but since you haven't shown us your struts-config.xml file or the <html:form> tag of your JSP, there's no way for me to tell. However, I do know that this is a very common error made by folks just getting used to Struts.
[ May 14, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

The action is created to load a list to be iterated after in the jsp.

The intention is to as many checkbox as item are in the list, so I think I don't need nay form now, do I?

Many tanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The rules of HTML are that any time you have an <input> tag, it must be enclosed in a <form> stanza. The answer to your question, then, is yes, you do need a form. You also need a submit button so that the user can submit the values to the server and have them be read by an action class.

If you want to use Struts custom tags, you should use <html:form> instead of <form>.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logic:iterate not bean found