/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package actions.books;

import com.google.inject.Inject;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import facade.BookFacadeLocal;
import models.Book;
import models.Level;

/**
 *
 * @author sergio
 */
public class PrePersistBookAction extends ActionSupport implements Preparable {
    @Inject
    private BookFacadeLocal bookFacade;
    private Integer idBook;
    private Book book;
    private Level[] levels;

    public Integer getIdBook() {
        return idBook;
    }

    public void setIdBook(Integer idBook) {
        this.idBook = idBook;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public Level[] getLevels() {
        return levels;
    }

    public void setLevels(Level[] levels) {
        this.levels = levels;
    }
    
    public String execute() throws Exception{
        return SUCCESS;
    }

    @Override
    public void prepare() throws Exception {
        levels = Level.values();
        if(idBook != null){
            book = bookFacade.find(idBook);
        }else{
            book = new Book();
        }
    }
    
}

@@ -366,16 +366,50 @@
 Local;%0D%0A
+import java.util.logging.Logger;%0D%0A
 import m
@@ -1029,99 +1029,48 @@
     
-return levels;%0D%0A    %7D%0D%0A%0D%0A    public void setLevels(Level%5B%5D levels) %7B%0D%0A        this.levels =
+levels = Level.values();%0D%0A        return
  lev
@@ -1234,42 +1234,8 @@
  %7B%0D%0A
-        levels = Level.values();%0D%0A
     

solve level list problem