Hi All,
I seem to be inexplicably running into TAP5-299
(https://issues.apache.org/jira/browse/TAP5-299), even though I'm not
doing that.

Code is below. If anything exists in the "selected" listed, I get an NPE.

Am I doing something wrong?

-----------------------------------------------------public class EditQuery {
    @Inject private QueryService queryService;
    @Inject private CategoryService categoryService;
    @Inject private Messages messages;

    @InjectPage private Queries queries;

    @Persist private Query query;

    @Property private final ValueEncoder<Category> encoder = new
CategoryValueEncoder(categoryService);

    @Property private final SelectModel model = new
CategorySelectModel(categoryService.getCategories());

    @Persist @Property private List<Category> selected;

    void onActivate() {
        selected = new ArrayList<Category>();
        selected.addAll(query.getCategories());
    }
    Object onActionFromCategoriesForm(){
        query.getCategories().clear();
        query.getCategories().addAll(selected);
        queryService.saveQuery(query);
        return queries;
    }
    public Query getQuery() {
        return query;
    }

    public void setQuery(Query query) {
        this.query = query;
    }

}
--------------------------------------
public class CategoryValueEncoder implements ValueEncoder<Category>{
        private CategoryService categoryService;

        public CategoryValueEncoder(CategoryService categoryService){
                this.categoryService = categoryService;
        }

        public String toClient(Category arg0) {
                return arg0.getCategoryName();
        }

        public Category toValue(String arg0) {
                return categoryService.getCategory(arg0);
        }


}
--------------------------------
public class CategorySelectModel implements SelectModel {
        private List<OptionModel> categories;
        
        public CategorySelectModel(List<Category> categories){
                this.categories = new ArrayList<OptionModel>();
                for (Category category : categories){
                        this.categories.add(new
OptionModelImpl(category.getCategoryName(),category));
                }
        }
        
        public List<OptionGroupModel> getOptionGroups() {
                return new ArrayList<OptionGroupModel>();
        }

        public List<OptionModel> getOptions() {
                return categories;
        }

        public void visit(SelectModelVisitor arg0) {
                for (OptionModel category : categories){
                        arg0.option(category);
                }
        }

}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to