简体   繁体   中英

java.io.NotSerializableException: ArtikelController

I am getting a java.io.NotSerializableException in my class ArtikelController. I really don't know how to solve this error.

Hope someone can help me. It only occured since i implemented a validator.

public class ArtikelController {

    private int index=0;
 public static void validateGTIN(FacesContext context, UIComponent component, Object value) 
          throws ValidatorException, IOException
  {
    String id = (String) value;
    int cipher = Artikel.berechnePrüfsumme(id);
    if (!id.endsWith(String.valueOf(cipher)))
    {
      throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, 
              id + " ist eine " + "fehlerhafte GTIN (erwartete Prüfziffer: " + 
                      cipher + ")", "")
      );
    }
  }
    public Artikel getArtikel() {
       return Shop.getInstance().getSortiment().get(index);
    }
    public void vor () {
        if(index<Shop.getInstance().getSortiment().size()-1);
        index++;
    }
    public void zurück () {
        if(index>0)
            index--;
    }
    public int getIndex() {
    return index;
  }
  
}

Implement Serializable in order to transform the object into the stream of bits. That's all, no need to implement any methods.

public class ArtikelController implements Serializable {
// 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM