/*
* $Id: SavePrefsAction.java 420385 2006-07-10 00:57:05Z mrdon $
*
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.struts2.portlet.example;
import javax.portlet.ActionRequest;
import javax.portlet.PortletPreferences;
import org.apache.struts2.portlet.context.PortletActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
*/
public class SavePrefsAction extends ActionSupport {
private String preferenceOne = null;
private String preferenceTwo = null;
public String getPreferenceOne() {
return preferenceOne;
}
public void setPreferenceOne(String preferenceOne) {
this.preferenceOne = preferenceOne;
}
public String getPreferenceTwo() {
return preferenceTwo;
}
public void setPreferenceTwo(String preferenceTwo) {
this.preferenceTwo = preferenceTwo;
}
public String execute() throws Exception {
ActionRequest req = PortletActionContext.getActionRequest();
PortletPreferences prefs = req.getPreferences();
prefs.setValue("preferenceOne", preferenceOne);
prefs.setValue("preferenceTwo", preferenceTwo);
prefs.store();
return SUCCESS;
}
public String showForm() throws Exception {
PortletPreferences prefs = PortletActionContext.getRequest().getPreferences();
preferenceOne = prefs.getValue("preferenceOne", "not set");
preferenceTwo = prefs.getValue("preferenceTwo", "not set");
return SUCCESS;
}
}