PortletPreferences pref = pcontext.getRequest().getPreferences();
String lastValue = pref.getValue(TOTAL_COLUMNS, "" + DEFAULT_COLUMNS);
if (uiInput.getValue() == null || uiInput.getValue().length() == 0) {
uiInput.setValue(lastValue);
throw new MessageException(new ApplicationMessage("EmptyFieldValidator.msg.empty-input", args));
}
int totalCols = 0;
try {
totalCols = Integer.parseInt(uiInput.getValue());
if (totalCols < 1 || totalCols > MAX_COLUMNS)
throw new Exception();
} catch (Exception e) {
uiInput.setValue(lastValue);
throw new MessageException(new ApplicationMessage("NumberRangeValidator.msg.Invalid-number", args));
}
UIDashboardContainer uiDashboardContainer = ((UIContainer) uiForm.getParent()).getChild(UIDashboard.class)
.getChild(UIDashboardContainer.class);
uiDashboardContainer.setColumns(totalCols);