0 Replies Latest reply on Jul 18, 2007 12:31 AM by Kgnytia

    Run-time error: 1074 Illegal write to read-only property _ on _

    Kgnytia
      Hello:
      I have a problem with serialization. I have a class ResultadoBusqueda with 2 properties: id and label. The label is serialized ok but there is an error getting the id. The result method of the Command receives an array of ResultadoBusqueda objets. This message appears in the Flex console: ReferenceError: Error #1074: Illegal write to read-only property id on common.entity.ResultadoBusqueda.

      Thank you all!

      Here it is the code.

      [Bindable]
      [RemoteClass(alias="entity.ResultadoBusqueda")]

      public class ResultadoBusqueda implements IExternalizable{
      private var _id : Number ;
      private var _label : String;

      public function readExternal(input:IDataInput):void {
      _id = input.readObject() as Number;
      _label = input.readObject() as String;
      }

      public function writeExternal(output:IDataOutput):void {
      output.writeObject(_id);
      output.writeObject(_label);
      }
      }

      This is the code in the result method of the Command:

      public function result( event : Object ) : void
      {
      var result : ArrayCollection = ArrayCollection((event as
      ResultEvent).result);
      ...
      }

      On debug, result is a org.granite.collections.UIDSet and each item is
      an object ResultadoBusqueda with and NaN id. The label is ok, though.

      And this is the code in the server side:

      public class ResultadoBusqueda implements Serializable {

      private static final long serialVersionUID = 8073121086769527302L;

      @Id @GeneratedValue
      private Integer id;
      private String label;

      public ResultadoBusqueda(){
      }
      public ResultadoBusqueda(Integer id,String label){
      this.id = id;
      this.label = label;
      }

      // Getters and Setters
      public Integer getId() {
      return id;
      }
      public void setId(Integer id) {
      this.id = id;
      }
      public String getLabel() {
      return label;
      }
      public void setLabel(String label) {
      this.label = label;
      }
      }