Author: liem_nguyen
Date: 2009-11-11 06:22:01 -0500 (Wed, 11 Nov 2009)
New Revision: 568
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
Log:
GTNPORTAL-229 Unknown error when add gadget into categories to be able used in Dashboard
in specical case
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2009-11-11
10:18:27 UTC (rev 567)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2009-11-11
11:22:01 UTC (rev 568)
@@ -3,6 +3,8 @@
import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.applicationregistry.webui.Util;
+import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
@@ -25,7 +27,7 @@
*/
@ComponentConfig(template = "system:/groovy/webui/form/UIForm.gtmpl", lifecycle
= UIFormLifecycle.class, events = {
@EventConfig(listeners = UICategorySelector.SaveActionListener.class),
- @EventConfig(listeners = UICategorySelector.CloseActionListener.class, phase =
Phase.DECODE)})
+ @EventConfig(listeners = UICategorySelector.CancelActionListener.class, phase =
Phase.DECODE)})
public class UICategorySelector extends UIForm
{
private List<ApplicationCategory> categories;
@@ -36,17 +38,39 @@
private final static String[] TABLE_COLUMNS = {"choose",
"categoryName"};
- public UICategorySelector() throws Exception
+ public UICategorySelector()
{
+ }
+
+ @Override
+ public boolean isRendered()
+ {
ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
- categories = appRegService.getApplicationCategories();
+ List<ApplicationCategory> categories;
+ try
+ {
+ categories = appRegService.getApplicationCategories();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
+ if (categories.isEmpty())
+ return false;
+ return super.isRendered();
}
- public void setup(Application app) throws Exception
+ /**
+ * @see Refresh each render time
+ */
+ @Override
+ public void processRender(WebuiRequestContext context) throws Exception
{
setChildren(null);
- this.application = app;
+ ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
+ List<ApplicationCategory> categories =
appRegService.getApplicationCategories(new Util.CategoryComparator());
+ categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
UIFormTableInputSet uiTableInputSet = createUIComponent(UIFormTableInputSet.class,
null, null);
uiTableInputSet.setName(getClass().getSimpleName());
@@ -57,28 +81,34 @@
UIFormInputSet uiInputSet;
UIFormCheckBoxInput<Boolean> checkBoxInput;
UIFormInputInfo uiInfo;
-
- ApplicationRegistryService appRegService =
getApplicationComponent(ApplicationRegistryService.class);
for (ApplicationCategory category : categories)
{
uiInputSet = new UIFormInputSet(category.getName());
- boolean defaultValue = appRegService.getApplication(category.getName(),
app.getApplicationName()) != null;
+ boolean defaultValue = false;
+ if (application != null)
+ {
+ String definitionName = application.getDisplayName().replace(' ',
'_');
+ defaultValue =
+ appRegService.getApplication(category.getName(), definitionName) != null;
+ }
checkBoxInput = new UIFormCheckBoxInput<Boolean>("category_" +
category.getName(), null, defaultValue);
uiInfo = new UIFormInputInfo("categoryName", null,
category.getDisplayName());
uiInputSet.addChild(checkBoxInput);
uiInputSet.addChild(uiInfo);
uiTableInputSet.addChild(uiInputSet);
}
+
+ super.processRender(context);
}
public String[] getActions()
{
return ACTIONS;
- }
+ }
- public List<ApplicationCategory> getCategories()
+ public void setApplication(Application app)
{
- return this.categories;
+ this.application = app;
}
public Application getApplication()
@@ -91,11 +121,12 @@
public void execute(Event<UICategorySelector> event) throws Exception
{
UICategorySelector selector = event.getSource();
- List<ApplicationCategory> categories = selector.getCategories();
- UIFormCheckBoxInput<Boolean> chkInput;
ApplicationRegistryService appRegService =
selector.getApplicationComponent(ApplicationRegistryService.class);
+ List<ApplicationCategory> categories =
appRegService.getApplicationCategories();
+ categories = categories != null ? categories : new
ArrayList<ApplicationCategory>();
+ UIFormCheckBoxInput<Boolean> chkInput;
for (ApplicationCategory category : categories)
- {
+ {
chkInput = selector.getUIInput("category_" + category.getName());
if (chkInput != null && chkInput.isChecked())
{
@@ -115,11 +146,12 @@
newApp.setType(app.getType());
newApp.setDescription(app.getDescription());
newApp.setAccessPermissions(app.getAccessPermissions());
+ newApp.setContentId(app.getContentId());
return newApp;
}
}
- static public class CloseActionListener extends
EventListener<UICategorySelector>
+ static public class CancelActionListener extends
EventListener<UICategorySelector>
{
public void execute(Event<UICategorySelector> event) throws Exception
{
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2009-11-11
10:18:27 UTC (rev 567)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetInfo.java 2009-11-11
11:22:01 UTC (rev 568)
@@ -99,7 +99,8 @@
for (ApplicationCategory category : allCategories)
{
- if (appRegService.getApplication(category.getName(), gadget_.getName()) !=
null)
+ String definitionName = gadget_.getTitle().replace(' ', '_');
+ if (appRegService.getApplication(category.getName(), definitionName) != null)
{
nameList.add(category.getDisplayName());
}
@@ -217,6 +218,15 @@
public void execute(Event<UIGadgetInfo> event) throws Exception
{
UIGadgetInfo gadgetInfo = event.getSource();
+
+ ApplicationRegistryService appRegService =
gadgetInfo.getApplicationComponent(ApplicationRegistryService.class);
+ List<ApplicationCategory> categories =
appRegService.getApplicationCategories();
+ if (categories == null || categories.isEmpty()) {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ uiApp.addMessage(new
ApplicationMessage("UICategorySelector.msg.NoCategory", null));
+ return;
+ }
+
Gadget gadget = gadgetInfo.getGadget();
UICategorySelector selector = gadgetInfo.getChild(UICategorySelector.class);
@@ -224,13 +234,14 @@
app.setApplicationName(gadget.getName());
app.setType(ApplicationType.GADGET);
app.setDisplayName(gadget.getTitle());
+ app.setContentId(gadget.getName());
String description =
(gadget.getDescription() == null || gadget.getDescription().length() < 1)
? gadget.getName() : gadget
.getDescription();
app.setDescription(description);
app.setAccessPermissions(new ArrayList<String>());
- selector.setup(app);
+ selector.setApplication(app);
selector.setRendered(true);
event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource());
}
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2009-11-11
10:18:27 UTC (rev 567)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_en.properties 2009-11-11
11:22:01 UTC (rev 568)
@@ -131,6 +131,7 @@
UICategorySelector.header.categoryName=Category's name
UICategorySelector.action.Save=Save
UICategorySelector.action.Cancel=Cancel
+UICategorySelector.msg.NoCategory=There is no any category
## org.exoplatform.applicationregistry.webui.component.UIAddGadget
UIAddGadget.action.Add=Add
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2009-11-11
10:18:27 UTC (rev 567)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2009-11-11
11:22:01 UTC (rev 568)
@@ -64,11 +64,7 @@
<a href="#" onclick="<%=
uicomponent.event("ShowCategories") %>"
style="color:red;text-decoration:underline;">
<%=_ctx.appRes("UIGadgetInfo.label.categories.clickHere")%>
</a>
- <% } else { %>
- <div>
- <% uicomponent.renderChildren() %>
- </div>
- <%}%>
+ <% } %>
<%}%>
</td>
@@ -77,4 +73,9 @@
</div>
</div>
+ <div>
+ <% if (categoryNames.equals("") && selectorRender) {
+ uicomponent.renderChildren();
+ } %>
+ </div>
</div>
\ No newline at end of file
Show replies by date