if (label.charAt(label.length() - 1) == ':') {
label = label.substring(0, label.length() - 1);
}
Object[] args = { label, String.valueOf(1), String.valueOf(MAX_COLUMNS) };
PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
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);
uiDashboardContainer.save();
if (Util.getUIPortalApplication().getModeState() == UIPortalApplication.NORMAL_MODE)
pcontext.setApplicationMode(PortletMode.VIEW);
}