Guys...
After a few fruitless hours of searching, I've yet to find an answer. So i throw this out in the hope that someone smarter than I can show me where I'm going wrong..
Is there a way to bind the "items" tag to a value in the referenceData at runtime? That is... in my form, i have a series of attributes being rendered and if they are of type "drop-down", I'm rendering a <form:select/> element with hopefully a reference to a String array in the reference data.
My current referenceData method in form controller has:
Code:protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { ... //obtain reference to my command object. Search search = (Search) command; //create a map to contain my "value-assistance" Map va = new LinkedHashMap(); //iterate through the attributes on my search for (int i = 0, ii = search.getAttributes().length; i < ii; i++) { Attribute a = search.getAttributes()[i]; // if we have a control of type COMBO; retrieve the list reference // data from the listManager. The listManager (singleton bean) returns a String[] array of value-assistance values. if (Attribute.CONTROLTYPE_COMBO.equalsIgnoreCase(a.getControltype())) { va.put(a.getName(), listManager.getMultiList(a.getName(),null)); } } map.addObject("va", va);
This means, I'll have say.. a Map in referenceData containing:
list1 = {"A","B","C"}
list2 = {"D", "E", "F"}
etc.
When i render the jsp, if i have a controltype = combo; then i'm rendering the following:
its the "items" that I can't quite figure out...Code:<form:select id="${a.name}" path="attributes[${attrid.index}].value" items="????/>
ie.
will work, it can retrieve the value from the map based on the referenceData available in the map. The list will contain A,B,C etc.Code:items="${va.list1}"
what i'd REALLY like to be able to do though is retrieve this at run-time... something like.. (doesn't work)
where. ${a.name} is the name of the list i'm trying to retrieve.Code:items="${va.${a.name}}"
Binding the items array at runtime rather than having to hard-code it - or make it a property of my Attribute class (since i'd like to retrieve these from the listManager singleton bean).
Will attach beer and peanuts for anyone that can assist!
Hope you can help.
A.


Reply With Quote