Java Code Examples for javax.portlet.ActionResponse#setWindowState()

The following examples show how to use javax.portlet.ActionResponse#setWindowState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferencesActionController.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@ActionMethod(portletName = "portlet1", actionName = "submitPreferences")
@CsrfProtected
public void submitPreferences(ActionRequest actionRequest, ActionResponse actionResponse) {

	ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale());

	models.put("preferences", new Preferences(datePattern));

	Set<ParamError> bindingErrors = bindingResult.getAllErrors();

	if (bindingErrors.isEmpty()) {

		try {
			portletPreferences.setValue("datePattern", datePattern);
			portletPreferences.store();
			actionResponse.setPortletMode(PortletMode.VIEW);
			actionResponse.setWindowState(WindowState.NORMAL);
			models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully"));
		}
		catch (Exception e) {
			models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred"));
			logger.error(e.getMessage(), e);
		}
	}
}
 
Example 2
Source File: PreferencesActionController.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@ActionMethod(portletName = "portlet1", actionName = "submitPreferences")
@CsrfProtected
public void submitPreferences(ActionRequest actionRequest, ActionResponse actionResponse) {

	ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale());

	models.put("preferences", new Preferences(datePattern));

	Set<ParamError> bindingErrors = bindingResult.getAllErrors();

	if (bindingErrors.isEmpty()) {

		try {
			portletPreferences.setValue("datePattern", datePattern);
			portletPreferences.store();
			actionResponse.setPortletMode(PortletMode.VIEW);
			actionResponse.setWindowState(WindowState.NORMAL);
			models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully"));
		}
		catch (Exception e) {
			models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred"));
			logger.error(e.getMessage(), e);
		}
	}
}
 
Example 3
Source File: PreferencesActionController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ActionMethod(portletName = "portlet1", actionName = "reset")
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfProtected
public void resetPreferences(ActionRequest actionRequest, ActionResponse actionResponse) {

	ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale());

	try {

		Enumeration<String> preferenceNames = portletPreferences.getNames();

		while (preferenceNames.hasMoreElements()) {
			String preferenceName = preferenceNames.nextElement();

			if (!portletPreferences.isReadOnly(preferenceName)) {
				portletPreferences.reset(preferenceName);
			}
		}

		portletPreferences.store();
		actionResponse.setPortletMode(PortletMode.VIEW);
		actionResponse.setWindowState(WindowState.NORMAL);
		models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully"));
	}
	catch (Exception e) {

		models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred"));

		logger.error(e.getMessage(), e);
	}
}
 
Example 4
Source File: PreferencesActionController.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@ActionMethod(portletName = "portlet1", actionName = "reset")
@ValidateOnExecution(type = ExecutableType.NONE)
@CsrfProtected
public void resetPreferences(ActionRequest actionRequest, ActionResponse actionResponse) {

	ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale());

	try {

		Enumeration<String> preferenceNames = portletPreferences.getNames();

		while (preferenceNames.hasMoreElements()) {
			String preferenceName = preferenceNames.nextElement();

			if (!portletPreferences.isReadOnly(preferenceName)) {
				portletPreferences.reset(preferenceName);
			}
		}

		portletPreferences.store();
		actionResponse.setPortletMode(PortletMode.VIEW);
		actionResponse.setWindowState(WindowState.NORMAL);
		models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully"));
	}
	catch (Exception e) {

		models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred"));

		logger.error(e.getMessage(), e);
	}
}