In my scenario, i'm developing nested select on a jsp, binded to a bean:
Bean
Now i have the Paneltype object, another simple beanCode:public class WizardPanelp1Bean { private Integer id; private Stringofpanels stringofpanels; private Paneltype paneltype; private Integer number; private String paneltypestring; //and getters/setters... [Omitted]
Paneltype
So, i prepare the view, with a bean named wb a simple arraylist of panelsCode:private Integer id; private double peakpower; private double weight; private String name; private double dimension; private double conversion; private Set functions = new HashSet(0); private Set sensors = new HashSet(0); private Set panels = new HashSet(0); //[Getters/setters omitted as usual]
and finally i go to the jsp (please note this is in a )Code:public class PanelsBean { private ArrayList<WizardPanelp1Bean> panels =new ArrayList<WizardPanelp1Bean>();
every time i get a null reference to paneltype. I obviousely used a @initbinder on the controller: InitbinderCode:<tbody> <c:forEach items="${wb.panels}" varStatus="loop" var="item"> <tr> <td>${item.id}</td> <td> <form:select path="panels[${loop.index}].paneltype" > <c:forEach var="type" items="${types}"> <c:choose> <c:when test="${item.paneltype.id==type.id}"> <form:option selected="selected" value="${type.id}" label="${type.name}" /> </c:when> <c:otherwise> <form:option value="${type.id}" label="${type.name}" /> </c:otherwise> </c:choose> </c:forEach> </form:select> </td> <td><form:input style="width:180px" path="panels[${loop.index}].number" /></td> <td> <div> <form:input style="visibility: hidden ; width:0px" path="panels[${loop.index}].id" disabled="disabled" /> <a href="javascript:remove(${item.id},${stringofpanels.id})" class="wb.panels.remove" >Rimuovi</a> </div> </td> </tr> </c:forEach> </tbody>
but the code never reach this. It's like the jsp is sure that the value is "null".Code:@InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { binder.registerCustomEditor(Paneltype.class, "paneltype", new PropertyEditorSupport() { @Override public void setAsText(String text) { int i=0; PaneltypeDAO pDAO=new PaneltypeDAO(); setValue(pDAO.findById(Integer.parseInt(text))); } }); }
Suggestions? Thanks


Reply With Quote
) next work with the framework instead of against the framework. Now lets clarify.


