Author: chris.laprun(a)jboss.com
Date: 2010-01-07 08:44:09 -0500 (Thu, 07 Jan 2010)
New Revision: 1195
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWSRPFormInputSet.java
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java
Log:
- Trying to control registration details via the registration required checkbox. Not
working so far. :( So this is mostly a synch commit.
- Added UIWSRPFormInputSet as default one has strange and undesirable layout behavior.
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWSRPFormInputSet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWSRPFormInputSet.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWSRPFormInputSet.java 2010-01-07
13:44:09 UTC (rev 1195)
@@ -0,0 +1,93 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.exoplatform.wsrp.webui.component;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormInputBase;
+import org.exoplatform.webui.form.UIFormInputSet;
+
+import java.io.Writer;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class UIWSRPFormInputSet extends UIFormInputSet
+{
+ public UIWSRPFormInputSet(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ if (getComponentConfig() != null)
+ {
+ super.processRender(context);
+ return;
+ }
+
+ StringBuilder sb = new StringBuilder(512);
+ sb.append("<div class=\"UIFormInputSet\">");
+
+ ResourceBundle res = context.getApplicationResourceBundle();
+ UIForm uiForm = getAncestorOfType(UIForm.class);
+ for (UIComponent inputEntry : getChildren())
+ {
+ if (inputEntry.isRendered())
+ {
+ sb.append("<div class=\"row\">");
+
+ String label;
+ try
+ {
+ label = uiForm.getLabel(res, inputEntry.getId());
+ if (inputEntry instanceof UIFormInputBase)
+ {
+ ((UIFormInputBase)inputEntry).setLabel(label);
+ }
+ }
+ catch (MissingResourceException ex)
+ {
+ //label = " " ;
+ label = inputEntry.getName();
+ System.err.println("\n " + uiForm.getId() + ".label."
+ inputEntry.getId() + " not found value");
+ }
+
+
sb.append("<label>").append(label).append("</label>");
+ renderUIComponent(inputEntry);
+
+ sb.append("</div>");
+ }
+ }
+ sb.append("</div>");
+
+ Writer w = context.getWriter();
+ w.write(sb.toString());
+ }
+}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java 2010-01-07
12:02:34 UTC (rev 1194)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java 2010-01-07
13:44:09 UTC (rev 1195)
@@ -39,8 +39,6 @@
import org.exoplatform.webui.form.UIFormCheckBoxInput;
import org.exoplatform.webui.form.UIFormInputBase;
import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
-import org.gatein.common.util.ParameterValidation;
import org.gatein.registration.RegistrationPolicy;
import org.gatein.registration.policies.DefaultRegistrationPolicy;
import org.gatein.wsrp.producer.config.ProducerConfiguration;
@@ -78,8 +76,10 @@
private static final String REQUIRES_REGISTRATION = "requiresregistration";
private static final String POLICY_CLASS = "policyClassName";
private static final String VALIDATOR_CLASS = "validatorClassName";
+ private static final String REGISTRATION_DETAILS = "registrationdetails";
private ProducerConfigurationService configService;
+ private UIWSRPFormInputSet registrationDetails;
public UIWsrpProducerEditor() throws Exception
{
@@ -95,10 +95,13 @@
popup.setRendered(false);
}
- public void initWith(ProducerConfigurationService configurationService) throws
Exception
+ public void setConfigService(ProducerConfigurationService configService)
{
- ParameterValidation.throwIllegalArgExceptionIfNull(configurationService,
"ProducerConfigurationService");
- configService = configurationService;
+ this.configService = configService;
+ }
+
+ private void init() throws Exception
+ {
ProducerConfiguration configuration = configService.getConfiguration();
ProducerRegistrationRequirements registrationRequirements =
configuration.getRegistrationRequirements();
@@ -108,12 +111,21 @@
boolean registrationRequired = registrationRequirements.isRegistrationRequired();
getUIFormCheckBoxInput(REQUIRES_REGISTRATION).setValue(registrationRequired);
+ // reset potentially existing registration details
+ if (registrationDetails != null)
+ {
+ removeChild(registrationDetails.getClass());
+ }
+
// if registration is required then we display more information
if (registrationRequired)
{
+ registrationDetails = new UIWSRPFormInputSet(REGISTRATION_DETAILS);
+
// registration policy
- UIFormInputBase<String> policyInput = new UIFormStringInput(POLICY_CLASS,
POLICY_CLASS, null).addValidator(MandatoryValidator.class);
+ UIFormInputBase<String> policyInput = new UIFormStringInput(POLICY_CLASS,
POLICY_CLASS, null);
addUIFormInput(policyInput);
+
RegistrationPolicy policy = registrationRequirements.getPolicy();
String policyClassName = policy.getClass().getName();
policyInput.setValue(policyClassName);
@@ -121,16 +133,16 @@
// if policy is the default one, display information about the validator
if
(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME.equals(policyClassName))
{
- UIFormInputBase<String> validatorInput = new
UIFormStringInput(VALIDATOR_CLASS, VALIDATOR_CLASS,
null).addValidator(MandatoryValidator.class);
- addUIFormInput(validatorInput);
+ UIFormInputBase<String> validatorInput = new
UIFormStringInput(VALIDATOR_CLASS, VALIDATOR_CLASS, null);
+ registrationDetails.addUIFormInput(validatorInput);
DefaultRegistrationPolicy defaultPolicy = (DefaultRegistrationPolicy)policy;
-
getUIStringInput(VALIDATOR_CLASS).setValue(defaultPolicy.getValidator().getClass().getName());
+ validatorInput.setValue(defaultPolicy.getValidator().getClass().getName());
}
// registration properties
Map<QName, RegistrationPropertyDescription> regProps =
configuration.getRegistrationRequirements().getRegistrationProperties();
- UIGrid uiGrid = addChild(UIGrid.class, "RegistrationPropertySelector",
null);
+ UIGrid uiGrid = registrationDetails.addChild(UIGrid.class,
"RegistrationPropertySelector", 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("name", FIELDS, SELECT_ACTIONS);
@@ -141,6 +153,8 @@
LazyPageList propertyList = createPageList(getPropertyList(regProps));
uiGrid.getUIPageIterator().setPageList(propertyList);
+ addUIFormInput(registrationDetails);
+ registrationDetails.setRendered(true);
}
}
@@ -228,8 +242,13 @@
registrationRequirements.setRegistrationRequiredForFullDescription(Boolean.parseBoolean(getUIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION).getValue().toString()));
producerConfiguration.setUsingStrictMode(Boolean.parseBoolean(getUIFormCheckBoxInput(STRICT_MODE).getValue().toString()));
-
registrationRequirements.setRegistrationRequired(Boolean.parseBoolean(getUIFormCheckBoxInput(REQUIRES_REGISTRATION).getValue().toString()));
-
registrationRequirements.reloadPolicyFrom(getUIStringInput(POLICY_CLASS).getValue(),
getUIStringInput(VALIDATOR_CLASS).getValue());
+ boolean requiresReg =
Boolean.parseBoolean(getUIFormCheckBoxInput(REQUIRES_REGISTRATION).getValue().toString());
+ registrationRequirements.setRegistrationRequired(requiresReg);
+ /*if (registrationDetails != null)
+ {
+
registrationRequirements.reloadPolicyFrom(registrationDetails.getUIStringInput(POLICY_CLASS).getValue(),
+ registrationDetails.getUIStringInput(VALIDATOR_CLASS).getValue());
+ }*/
configService.saveConfiguration();
uiApp.addMessage(new ApplicationMessage("Producer Successfully
Changed", null));
@@ -307,4 +326,13 @@
}
}
+
+ @Override
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ // reset the GUI
+ init();
+
+ super.processRender(context);
+ }
}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java 2010-01-07
12:02:34 UTC (rev 1194)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java 2010-01-07
13:44:09 UTC (rev 1195)
@@ -41,7 +41,7 @@
public UIWsrpProducerOverview() throws Exception
{
producerForm = createUIComponent(UIWsrpProducerEditor.class, null, "Producer
Editor");
- producerForm.initWith(getProducerConfigurationService());
+ producerForm.setConfigService(getProducerConfigurationService());
addChild(producerForm);
}