Author: hfnukal
Date: 2011-03-30 05:02:48 -0400 (Wed, 30 Mar 2011)
New Revision: 6137
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
Log:
JBEPP-773: "Preferences" tab is only showing up if portlet has been customized
(Only possible though portal.xml)
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java 2011-03-29
19:21:55 UTC (rev 6136)
+++
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java 2011-03-30
09:02:48 UTC (rev 6137)
@@ -167,34 +167,34 @@
UIForm uiForm = getAncestorOfType(UIForm.class);
for (UIComponent inputEntry : getChildren())
{
- if (inputEntry.isRendered())
+ if (inputEntry instanceof UIFormInputBase)
{
- String label;
- try
+ if (inputEntry.isRendered())
{
- label = uiForm.getLabel(res, inputEntry.getId());
- if (inputEntry instanceof UIFormInputBase)
- ((UIFormInputBase)inputEntry).setLabel(label);
+ UIFormInputBase formInputBase = (UIFormInputBase) inputEntry;
+ String label;
+ if (formInputBase.getLabel() != null)
+ {
+ label = uiForm.getLabel(res, formInputBase.getLabel());
+ }
+ else
+ {
+ label = uiForm.getLabel(res, formInputBase.getId());
+ }
+ w.write("<tr>");
+ w.write("<td class=\"FieldLabel\">");
+
+ // if missing resource and the label hasn't been set before, don't
print out the label.
+ if (formInputBase.getLabel() != null || (label != formInputBase.getId()))
+ {
+ w.write(label);
+ }
+ w.write("</td>");
+ w.write("<td class=\"FieldComponent\">");
+ renderUIComponent(formInputBase);
+ w.write("</td>");
+ w.write("</tr>");
}
- catch (MissingResourceException ex)
- {
- //label = " " ;
- label = inputEntry.getName();
- System.err.println("\n " + uiForm.getId() + ".label."
+ inputEntry.getId() + " not found value");
- }
- w.write("<tr>");
- w.write("<td class=\"FieldLabel\">");
-
- // if missing resource, don't print out the label.
- if(!label.equals(inputEntry.getName()))
- {
- w.write(label);
- }
- w.write("</td>");
- w.write("<td class=\"FieldComponent\">");
- renderUIComponent(inputEntry);
- w.write("</td>");
- w.write("</tr>");
}
}
w.write("</table>");
@@ -214,4 +214,4 @@
}
}
-}
\ No newline at end of file
+}
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-03-29
19:21:55 UTC (rev 6136)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-03-30
09:02:48 UTC (rev 6137)
@@ -22,8 +22,8 @@
import org.exoplatform.commons.utils.ExceptionUtil;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.pc.ExoPortletState;
-import org.exoplatform.portal.pom.spi.portlet.Preference;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.portlet.Preference;
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
import org.exoplatform.portal.pom.spi.wsrp.WSRPPortletStateType;
import org.exoplatform.portal.portlet.PortletExceptionHandleService;
@@ -45,22 +45,15 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.Event.Phase;
import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIFormCheckBoxInput;
-import org.exoplatform.webui.form.UIFormInputIconSelector;
-import org.exoplatform.webui.form.UIFormInputInfo;
-import org.exoplatform.webui.form.UIFormInputSet;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.UIFormTabPane;
-import org.exoplatform.webui.form.UIFormTextAreaInput;
+import org.exoplatform.webui.form.*;
import org.exoplatform.webui.form.validator.ExpressionValidator;
import org.exoplatform.webui.form.validator.MandatoryValidator;
import org.exoplatform.webui.form.validator.StringLengthValidator;
import org.exoplatform.webui.organization.UIListPermissionSelector;
import
org.exoplatform.webui.organization.UIListPermissionSelector.EmptyIteratorValidator;
import org.gatein.pc.api.Mode;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.api.StatefulPortletContext;
+import org.gatein.pc.api.info.PreferenceInfo;
import org.gatein.pc.api.invocation.RenderInvocation;
import org.gatein.pc.api.invocation.response.ErrorResponse;
import org.gatein.pc.api.invocation.response.FragmentResponse;
@@ -68,23 +61,12 @@
import org.gatein.pc.api.spi.InstanceContext;
import org.gatein.pc.api.state.AccessMode;
import org.gatein.pc.api.state.PropertyChange;
-import org.gatein.pc.portlet.impl.spi.AbstractClientContext;
-import org.gatein.pc.portlet.impl.spi.AbstractPortalContext;
-import org.gatein.pc.portlet.impl.spi.AbstractSecurityContext;
-import org.gatein.pc.portlet.impl.spi.AbstractServerContext;
-import org.gatein.pc.portlet.impl.spi.AbstractUserContext;
-import org.gatein.pc.portlet.impl.spi.AbstractWindowContext;
+import org.gatein.pc.portlet.impl.spi.*;
import javax.portlet.PortletMode;
import javax.servlet.http.Cookie;
+import java.util.*;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.ResourceBundle;
-
/** Author : Nhu Dinh Thuan nhudinhthuan(a)yahoo.com Jun 8, 2006 */
@ComponentConfigs({
@ComponentConfig(lifecycle = UIFormLifecycle.class, template =
"system:/groovy/portal/webui/portal/UIPortletForm.gtmpl", events = {
@@ -115,7 +97,7 @@
addValidator(MandatoryValidator.class).setEditable(false)).
addUIFormInput(new UIFormStringInput("windowId", "windowId",
null).setEditable(false)).*/
addUIFormInput(new UIFormInputInfo("displayName",
"displayName", null)).addUIFormInput(
- new UIFormStringInput("title", "title",
null).addValidator(StringLengthValidator.class, 3,
60).addValidator(ExpressionValidator.class, "[^\\<\\>]*",
+ new UIFormStringInput("title", "title",
null).addValidator(StringLengthValidator.class, 3,
60).addValidator(ExpressionValidator.class, "[^\\<\\>]*",
"UIPortletForm.msg.InvalidPortletTitle"))
.addUIFormInput(
new UIFormStringInput("width", "width",
null).addValidator(ExpressionValidator.class, "(^([1-9]\\d*)px$)?",
@@ -226,7 +208,7 @@
{
content = fragmentResponse.getContent();
}
-
+
}
else
{
@@ -262,7 +244,7 @@
}
portletContent.setLength(0);
-
+
portletContent.append(content);
}
catch (Throwable ex)
@@ -288,40 +270,59 @@
getChild(UIFormInputIconSelector.class).setSelectedIcon(icon);
getChild(UIFormInputThemeSelector.class).getChild(UIItemThemeSelector.class).setSelectedTheme(
uiPortlet.getSuitedTheme(null));
- WebuiRequestContext contextres = WebuiRequestContext.getCurrentInstance();
- ResourceBundle res = contextres.getApplicationResourceBundle();
if (hasEditMode())
{
uiPortlet.setCurrentPortletMode(PortletMode.EDIT);
}
else
{
+ Map<String, String> portletPreferenceMaps = new HashMap<String,
String>();
+ org.gatein.pc.api.Portlet portlet = uiPortlet.getProducedOfferedPortlet();
+ Set<String> keySet = portlet.getInfo().getPreferences().getKeys();
- //
+ for (String key : keySet)
+ {
+ PreferenceInfo preferenceInfo =
portlet.getInfo().getPreferences().getPreference(key);
+ if (!preferenceInfo.isReadOnly())
+ {
+ String ppValue = (preferenceInfo.getDefaultValue().size() > 0) ?
preferenceInfo.getDefaultValue().get
+ (0) : "";
+ portletPreferenceMaps.put(key, ppValue);
+ }
+ }
+
Portlet pp = uiPortlet.getPreferences();
if (pp != null)
{
- UIFormInputSet uiPortletPrefSet = getChildById(FIELD_PORTLET_PREF);
- uiPortletPrefSet.getChildren().clear();
for (Preference pref : pp)
{
if (!pref.isReadOnly())
{
- UIFormStringInput templateStringInput =
- new UIFormStringInput(pref.getName(), null,
pref.getValues().get(0));
-
templateStringInput.setLabel(res.getString("UIPortletForm.tab.label.Template"));
- templateStringInput.addValidator(MandatoryValidator.class);
- uiPortletPrefSet.addUIFormInput(templateStringInput);
+ portletPreferenceMaps.put(pref.getName(), (pref.getValues().size() >
0) ? pref.getValues().get(0) :
+ "");
}
-
}
- if (uiPortletPrefSet.getChildren().size() > 0)
+ }
+
+ if (portletPreferenceMaps.size() > 0)
+ {
+ Set<String> ppKeySet = portletPreferenceMaps.keySet();
+ UIFormInputSet uiPortletPrefSet = getChildById(FIELD_PORTLET_PREF);
+ uiPortletPrefSet.getChildren().clear();
+ for (String ppKey : ppKeySet)
{
- uiPortletPrefSet.setRendered(true);
- setSelectedTab(FIELD_PORTLET_PREF);
- return;
+ String ppValue = portletPreferenceMaps.get(ppKey);
+ UIFormStringInput preferenceStringInput = new UIFormStringInput(ppKey,
null, ppValue);
+ preferenceStringInput.setLabel(ppKey);
+ preferenceStringInput.addValidator(MandatoryValidator.class);
+ uiPortletPrefSet.addUIFormInput(preferenceStringInput);
}
+
+ uiPortletPrefSet.setRendered(true);
+ setSelectedTab(FIELD_PORTLET_PREF);
+ return;
}
+
setSelectedTab("PortletSetting");
}
}
@@ -336,12 +337,6 @@
return;
}
- //
- PortletInvoker portletInvoker = getApplicationComponent(PortletInvoker.class);
- PortletContext portletContext = uiPortlet_.getPortletContext();
-
- //
-
PropertyChange[] propertyChanges = new PropertyChange[uiFormInputs.size()];
for (int i = 0; i < uiFormInputs.size(); i++)