if(action.equals("add_preference"))
{
String name = actionRequest.getParameter("name");
String value = actionRequest.getParameter("value");
PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(name);
if(pref == null)
{
portlet.addPreference(name, new String[] { value });
}
else
{
pref.addValue(value);
}
registry.savePortletDefinition(portlet);
}
else if(action.equals("edit_preference"))
{
String[] prefNames = actionRequest.getParameterValues("pref_edit_id");
for (int i = 0; i < prefNames.length; i++)
{
String prefName = prefNames[i];
PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
String[] values = prefComp.getValueArray();
for (int j = 0; j < values.length; j++)
{
String value = values[j];
String newValue = actionRequest.getParameter(prefName + ":" + j);
if(!value.equals(newValue))
{
prefComp.setValueAt(j, newValue);
}
}
}
registry.savePortletDefinition(portlet);
}
else if(action.equals("remove_preference"))
{
String[] prefNames = actionRequest.getParameterValues("pref_remove_id");
Iterator prefIter = portlet.getPreferenceSet().iterator();
while (prefIter.hasNext())
{
PreferenceComposite pref = (PreferenceComposite) prefIter.next();
String name = pref.getName();
for(int i=0; i<prefNames.length; i++)
{
String prefName = prefNames[i];
if(name.equals(prefName))