Author: wesleyhales
Date: 2009-12-18 17:37:20 -0500 (Fri, 18 Dec 2009)
New Revision: 1075
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl
Log:
consumer ajax ui interaction working, form almost done - needs binding to objects.
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java
===================================================================
---
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java 2009-12-18
19:42:17 UTC (rev 1074)
+++
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java 2009-12-18
22:37:20 UTC (rev 1075)
@@ -25,6 +25,7 @@
import org.exoplatform.applicationregistry.webui.component.UIAddApplicationForm;
import org.exoplatform.applicationregistry.webui.component.UIApplicationForm;
import org.exoplatform.applicationregistry.webui.component.UIApplicationOrganizer;
+import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.web.application.ApplicationMessage;
@@ -32,12 +33,17 @@
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UIGrid;
+import org.exoplatform.webui.core.UIPopupWindow;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormCheckBoxInput;
import org.exoplatform.webui.form.UIFormStringInput;
import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.exoplatform.webui.organization.UIAccountInputSet;
import org.gatein.wsrp.WSRPConsumer;
import org.gatein.wsrp.consumer.ConsumerException;
import org.gatein.wsrp.consumer.WSRPConsumerImpl;
@@ -49,16 +55,53 @@
public class UIWsrpConsumerEditor extends UIForm
{
protected static final String CONSUMER_NAME = "producerId";
+ protected static final String CACHE_EXPIRATION = "Cache Expiration";
+ protected static final String USE_WSDL = "Use WSDL";
+ protected static final String SERVICE_DESC_URL = "Service Description URL";
+ protected static final String MARKUP_URL = "Markup URL";
+ protected static final String REG_URL = "Registration URL";
+ protected static final String PORTLET_MGMT_URL = "Portlet Management URL";
public UIWsrpConsumerEditor() throws Exception
{
addUIFormInput(new UIFormStringInput(CONSUMER_NAME, CONSUMER_NAME,
null).addValidator(MandatoryValidator.class));
+ addUIFormInput(new UIFormStringInput(CACHE_EXPIRATION, CACHE_EXPIRATION, null));
+ addUIFormInput(new UIFormCheckBoxInput(USE_WSDL, USE_WSDL, null));
+ addUIFormInput(new UIFormStringInput(SERVICE_DESC_URL, SERVICE_DESC_URL, null));
+ addUIFormInput(new UIFormStringInput(MARKUP_URL, MARKUP_URL, null));
+ addUIFormInput(new UIFormStringInput(REG_URL, REG_URL, null));
+ addUIFormInput(new UIFormStringInput(PORTLET_MGMT_URL, PORTLET_MGMT_URL, null));
+
}
private String getConsumerName(){
return getUIStringInput(CONSUMER_NAME).getValue();
}
+ private String getCacheExpiration(){
+ return getUIStringInput(CACHE_EXPIRATION).getValue();
+ }
+
+ private Object isUseWsdl(){
+ return getUIFormCheckBoxInput(USE_WSDL).getValue();
+ }
+
+ private String getServiceDescriptionUrl(){
+ return getUIStringInput(SERVICE_DESC_URL).getValue();
+ }
+
+ private String getMarkupUrl(){
+ return getUIStringInput(MARKUP_URL).getValue();
+ }
+
+ private String getRegistrationUrl(){
+ return getUIStringInput(REG_URL).getValue();
+ }
+
+ private String getPortletMgmtUrl(){
+ return getUIStringInput(PORTLET_MGMT_URL).getValue();
+ }
+
public void setConsumer(WSRPConsumer consumer) throws Exception{
if (consumer == null)
{
@@ -74,8 +117,34 @@
public void execute(Event<UIWsrpConsumerEditor> event) throws Exception
{
UIWsrpConsumerEditor consumerEditor = event.getSource();
+
+ UIWsrpConsumerOverview consumerOverview =
consumerEditor.getAncestorOfType(UIWsrpConsumerOverview.class);
+
+
+
WebuiRequestContext ctx = event.getRequestContext();
consumerEditor.save(ctx);
+ //loose the popup
+
+ //update the consumer grid/list using ajax
+
//event.getRequestContext().addUIComponentToUpdateByAjax(consumerEditor.getParent().getParent().findComponentById("ConsumerSelector"));
+
+ //getChild(UIAccountInputSet.class).reset();
+ UIPopupWindow popup = consumerEditor.getParent();
+ popup.setRendered(false);
+ popup.setShow(false);
+ popup.setUIComponent(null);
+
+
+
+ LazyPageList pageList =
consumerOverview.createPageList(consumerOverview.getTempArrayList());
+ UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
+ uiGrid.getUIPageIterator().setPageList(pageList);
+
+ ctx.addUIComponentToUpdateByAjax(consumerOverview);
+
+
//consumerOverview.renderUIComponent(consumerEditor.getParent().getParent().findComponentById("ConsumerSelector"));
+ //ctx.sendRedirect(consumerOverview.url("wsrp"));
}
}
@@ -97,8 +166,8 @@
//consumer = new WSRPConsumerImpl();
-
+
System.out.println("----------getConsumerName: " + getConsumerName());
return true;
}
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java
===================================================================
---
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java 2009-12-18
19:42:17 UTC (rev 1074)
+++
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java 2009-12-18
22:37:20 UTC (rev 1075)
@@ -66,7 +66,8 @@
@EventConfig(listeners = UIWsrpConsumerOverview.StartActionListener.class),
@EventConfig(listeners = UIWsrpConsumerOverview.StopActionListener.class),
@EventConfig(listeners = UIWsrpConsumerOverview.RefreshActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.DeactivateActionListener.class)
+ @EventConfig(listeners =
UIWsrpConsumerOverview.DeactivateActionListener.class),
+ @EventConfig(listeners =
UIWsrpConsumerOverview.RefreshGridActionListener.class)
})
})
@@ -80,37 +81,27 @@
//
public static String[] SELECT_ACTIONS =
{"Edit","Delete","Refresh","Deactivate","Start","Stop"};
- public UIWsrpConsumerOverview() throws Exception
+ private List tempArrayList;
+
+ public List getTempArrayList()
{
- UIPopupWindow popup = addChild(UIPopupWindow.class, null, null);
- popup.setWindowSize(400, 300);
- UIWsrpConsumerEditor consumerForm = createUIComponent(UIWsrpConsumerEditor.class,
null, null);
- popup.setUIComponent(consumerForm);
- popup.setRendered(false);
-
ExoContainer manager = ExoContainerContext.getCurrentContainer();
ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+ return consumerRegistry.getConfiguredConsumers();
+ }
- UIGrid uiGrid = addChild(UIGrid.class, "ConsumerSelector", null);
- //configure the edit and delete buttons based on an id from the data list - this
will also be passed as param to listener
- uiGrid.configure("producerId", FIELDS, SELECT_ACTIONS);
-
- uiGrid.getUIPageIterator().setId("ChangeConsumerPageIterator");
- addChild(uiGrid.getUIPageIterator());
- uiGrid.getUIPageIterator().setRendered(false);
- final List tempArrayList = consumerRegistry.getConfiguredConsumers();
-
- LazyPageList pageList = new LazyPageList(new ListAccess<WSRPConsumer>()
+ public LazyPageList createPageList(final List pageList){
+ return new LazyPageList(new ListAccess<WSRPConsumer>()
{
public int getSize() throws Exception
{
- return tempArrayList.size();
+ return pageList.size();
}
public WSRPConsumer[] load(int index, int length) throws Exception,
IllegalArgumentException
{
- WSRPConsumer[] pcs = new WSRPConsumer[tempArrayList.size()];
+ WSRPConsumer[] pcs = new WSRPConsumer[pageList.size()];
if (index < 0)
{
@@ -122,7 +113,7 @@
throw new IllegalArgumentException("Illegal length: length must be a
positive number");
}
- if (index + length > tempArrayList.size())
+ if (index + length > pageList.size())
{
throw new IllegalArgumentException(
"Illegal index or length: sum of the index and the length cannot
be greater than the list size");
@@ -130,16 +121,53 @@
for (int i = 0; i < length; i++)
{
- pcs[i] = (WSRPConsumer)tempArrayList.get(i + index);
+ pcs[i] = (WSRPConsumer)pageList.get(i + index);
}
return pcs;
}
}, 10);
+ }
+
+ public UIWsrpConsumerOverview() throws Exception
+ {
+ UIPopupWindow popup = addChild(UIPopupWindow.class, null, null);
+ popup.setWindowSize(400, 300);
+ UIWsrpConsumerEditor consumerForm = createUIComponent(UIWsrpConsumerEditor.class,
null, null);
+ popup.setUIComponent(consumerForm);
+ popup.setRendered(false);
+
+ UIGrid uiGrid = addChild(UIGrid.class, "ConsumerSelector", null);
+ //configure the edit and delete buttons based on an id from the data list - this
will also be passed as param to listener
+ uiGrid.configure("producerId", FIELDS, SELECT_ACTIONS);
+
+ uiGrid.getUIPageIterator().setId("ChangeConsumerPageIterator");
+ addChild(uiGrid.getUIPageIterator());
+ uiGrid.getUIPageIterator().setRendered(false);
+ tempArrayList = getTempArrayList();
+
+ LazyPageList pageList = createPageList(getTempArrayList());
uiGrid.getUIPageIterator().setPageList(pageList);
}
+ static public class RefreshGridActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ WebuiRequestContext ctx = event.getRequestContext();
+
+ UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
+ //refresh the list
+ LazyPageList pageList =
consumerOverview.createPageList(consumerOverview.getTempArrayList());
+ uiGrid.getUIPageIterator().setPageList(pageList);
+
+ ctx.addUIComponentToUpdateByAjax(consumerOverview);
+
+ }
+ }
+
static public class OpenPopupActionListener extends
EventListener<UIWsrpConsumerOverview>
{
public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
@@ -152,6 +180,9 @@
editor.setConsumer(null);
popup.setRendered(true);
popup.setShow(true);
+ popup.setShowCloseButton(true);
+ popup.setShowMask(true);
+
}
}
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl
===================================================================
---
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl 2009-12-18
19:42:17 UTC (rev 1074)
+++
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl 2009-12-18
22:37:20 UTC (rev 1075)
@@ -7,9 +7,10 @@
%>
-<div class="<%=uicomponent.getId()%>">
+<div class="<%=uicomponent.getId()%>"
id="<%=uicomponent.getId()%>">
- <a href="<%=uicomponent.event("OpenPopup",
"")%>">Add Consumer</a>
+ <a href="<%=uicomponent.event("OpenPopup",
"")%>">Add Consumer</a> |
+ <a href="<%=uicomponent.event("RefreshGrid",
"")%>">Refresh List</a>
<% uicomponent.renderChildren(); %>
</div>
\ No newline at end of file