You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nobody <da...@budweiser.com> on 2007/04/17 00:15:07 UTC

Re: "Could not find a strategy instance for class RubricSelectionModel" when working with PropertySelection component

 
#mypost3265 pre { 
  font-size: 140%;
  border-style: outset;
  border-color: red;
}



I'm sure this post is useless for you, but I figured I should correct this
anyway for others' reference.

To be serializable,  you should implement these 2 methods:
   private void writeObject(java.io.ObjectOutputStream out)
     throws IOException
   private void readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException;

It is explained in the JavaDoc for j2se: 
   http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html 
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html 
   

With what you had, my guess was that rubricList would just be null after
deserialization, not the exception you got, but this is what you should do
anyway.


Here is the class with those methods implemented:


import java.io.*;

public class RubricSelectionModel implements Serializable{
      private static final long serialVersionUID = 1L;

      private List rubricList;

        public RubricSelectionModel(List itemList) {
            this.rubricList = itemList;
        }

        public int getOptionCount() { return rubricList.size(); }

        public Object getOption(int index) {
            return rubricList.get(index);
        }

        public String getLabel(int index) {
            return ((Rubric) rubricList.get(index)).getName();
        }

        public String getValue(int index) {
              return ((Rubric) rubricList.get(index)).getId().toString();
        }

        public Object translateValue(String value) {
              Iterator e = rubricList.iterator();
              while(e.hasNext()){
                    Rubric rubric = (Rubric)e.next();
                    if(rubric.getId().toString() == value){
                          return rubric;
                    }
              }
              return null;
        }

        private void writeObject(java.io.ObjectOutputStream out)  throws
IOException {
                out.writeObject( rubricList );
        }
        private void readObject(java.io.ObjectInputStream in) throws
IOException, ClassNotFoundException {
                rubricList = (List)in.readObject();
        }

} 

-- 
View this message in context: http://www.nabble.com/%22Could-not-find-a-strategy-instance-for-class-RubricSelectionModel%22-when-working-with-PropertySelection-component-tf2046393.html#a10025753
Sent from the Tapestry - User mailing list archive at Nabble.com.