Hello,
 
I was going through your excellent article at
http://appfuse.org/display/APF/Using+Spring+MVC#UsingSpringMVC-controlle
rform
<http://appfuse.org/display/APF/Using+Spring+MVC#UsingSpringMVC-controll
erform> 
I am great fan of appfuse.
 
I do have one question though in context of SPRING framework.
I would be grateful if you could take a moment from your busy  schedule
and answer it.

 
I am having formBackingObject with ArrayList as one of the fileds with
objects of one POJO like
 
public class DataVendor implements Serializable
{
 public String vendorID;
 public String name;
}
 
On JSP I am going to iterate over this arraylist with vendorID as value
and name as label to prepare my multi select dropdown box.
I am using SPRING 2.5.2 and <form:select> tag.
 
This forces me to create a CustomEditor for converting the string back
into object and register it thourgh.
binder.registerCustomEditor(ArrayList.class, new MyCustomEditor());
The only 2 methods that I implemented are as follows.
It is not working because of ClassCastException.
 
Please help me out. I really need you at this point of time.
 
 
 
 public String getAsText()
 {
    ArrayList al = (ArrayList) getValue();     -------> exception occurs
here because the getValue returns DataVendor.java
   for(int i= 0; i < al.size(); i++)
   {
        DataVendor dv = (DataVendor)al.get(i);
        s = s + dv.getVendorID();
    }
   return s;
 }
 
 
 public void setAsText(final String text)
 {
   ArrayList newal = new ArrayList();
   ArrayList dataVendor = (ArrayList)ctx.getAttribute("DATA_VENDOR");
----> coming from ServletContext
 
   StringTokenizer st = new StringTokenizer(text, ",");
   while(st.hasMoreTokens() == true)
   {
       String s = st.nextToken();
      for (int i=0; i < dataVendor.size(); i++)
     {
         DataVendor dv = (DataVendor)dataVendor.get(i);
        if(dv.getVendorID().equalsIgnoreCase(s) == true)
       {
           newal.add(dv);
     }
    }
   }
  setValue(newal);
 }



 
 
Thanks.
Chirag
 

This e-mail and its attachments are confidential and solely for the
intended addressee(s). Do not share or use them without Fannie Mae's
approval. If received in error, contact the sender and delete them.

 
 

This e-mail and its attachments are confidential and solely for the
intended addressee(s). Do not share or use them without Fannie Mae's
approval. If received in error, contact the sender and delete them.

 

Reply via email to