i want to achieve groupListing in tapestry using OptionGroupModel and OptionModel. I get a NULL pointer error with the SelectModelImpl. I dont know where i am going wrong with this. Another isssue is that when i manage to display them in group using another way, the selected models when deselected they refresh the page while remaining unselected.
<div t:type="ck/Tooltip" title="${message:savedCriteria.ttpTitle}" value="${message:savedCriteria.ttpValue}" effect="appear">
<t:select t:id="SavedCriteria" validate="required" model="savedCriteria" value="prop:currentCriteria" t:mixins="OnSelectChangeActionLink" optionModels="savedCriteria.options" selectChangeEncoder="singleValueEncoder" />
</div>
The code for grabbing the formulars is as follows:
public SelectModel getFormulas() throws Exception {
//return new SelectModelImpl(createOptionGroups(getFormulaList(), getFormulaLabelList()), null);
//return new SelectModelImpl(selectService.getFormulaGroupByWhereClause("T_FORMULALIST", "ID", "FORMULANAME", "LOCALEPARENT", LanguageQueries.getLanguageByCode(getUserLanguage()), "showInAnalyzer", true, this.listFormulas), null);
return new AbstractSelectModel() {
private List<OptionGroupModel> groupModels = null;
public List<OptionModel> getOptions() {
return null;
}
public List<OptionGroupModel> getOptionGroups() {
if (groupModels == null) {
computeModel();
}
return groupModels;
}
private void computeModel() {
groupModels = createOptionGroups(getFormulaList(), getFormulaLabelList());
}
};
}
private List<OptionGroupModel> createOptionGroups(LinkedHashMap<String, Integer> formulaList, LinkedHashMap<String, String> formulaLabelList)
{
final List<OptionGroupModel> optGroupList = new ArrayList<OptionGroupModel>();
for (Iterator<?> iterator = formulaLabelList.keySet().iterator(); iterator.hasNext(); ) {
String key = (String) iterator.next();
String group = formulaLabelList.get(key);
List<OptionModel> optList = new ArrayList<OptionModel>();
for (Iterator<?> i = formulaList.keySet().iterator(); i.hasNext(); ) {
String optionKey = (String) i.next();
Integer option = formulaList.get(optionKey);
String optionCompare = formulaList.get(optionKey).toString();
if(key.equalsIgnoreCase("Uncategorized") && option == null){
optList.add(new OptionModelImpl(optionKey, option));
} else if((optionCompare.contains(group)) && !(optionKey.contains("*"))) {
optList.add(new OptionModelImpl(optionKey, option));
}
}
if(optList.size() > 0) {
OptionGroupModel groupModel = new OptionGroupModelImpl(key, false, optList);
optGroupList.add(groupModel);
}
}
return optGroupList;
}
Kindly assist me assist where i am going wrong. What i want to achieve is when select items, i should also return them to the available list.
I solved this by creating a javascript file that moves the results to the selected side and vice verser, I also create the groups in the javascript file using tag