Permalink
Browse files

* 为form-tool添加参数,使之可以指定formService的实例:<form-tool formServiceRef="xxx" />

  • Loading branch information...
1 parent de8fde8 commit 0d9b2df657013f033cecf2d6fae5be0dd194a058 Michael Zhou committed Aug 16, 2012
View
@@ -1,5 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
+ <file url="file://$PROJECT_DIR$" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/common/expr" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/common/generictype" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/common/hessian" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/common/logconfig" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/common/springext" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/common/util" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/dist/test" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/dist/webx" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/base" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/configuration" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/dataresolver" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/form" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/freemarker" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/jsp" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/mail" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/mappingrule" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/moduleloader" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/pipeline" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/pull" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/requestcontext" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/resource" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/template" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/upload" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/uribroker" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/service/velocity" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/test/util" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/test/webx" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/webx/dev" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/webx/framework" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/webx/turbine" charset="UTF-8" />
+ </component>
</project>
View
@@ -304,3 +304,5 @@
* 添加一种新的module adapter: <screen-event-adapter />,从而支持如下情形:
当target=/xxx/yyy/zzz.htm时,调用screen.xxx.Yyy中的doZzz()方法。
原来的方式仍然支持。
+
+* 为form-tool添加参数,使之可以指定formService的实例:<form-tool formServiceRef="xxx" />
View
@@ -47,3 +47,5 @@
* 添加一种新的module adapter: <screen-event-adapter />,从而支持如下情形:
当target=/xxx/yyy/zzz.htm时,调用screen.xxx.Yyy中的doZzz()方法。
原来的方式仍然支持。
+
+* 为form-tool添加参数,使之可以指定formService的实例:<form-tool formServiceRef="xxx" />
@@ -21,6 +21,7 @@
import static com.alibaba.citrus.util.Assert.*;
import static com.alibaba.citrus.util.BasicConstant.*;
import static com.alibaba.citrus.util.ObjectUtil.*;
+import static com.alibaba.citrus.util.StringUtil.*;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
@@ -36,6 +37,9 @@
import com.alibaba.citrus.util.StringEscapeUtil;
import org.apache.ecs.xhtml.input;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
/**
* 便于模板使用的pull tool。
@@ -325,5 +329,13 @@ public void remove() {
}
public static class DefinitionParser extends AbstractSingleBeanDefinitionParser<FormTool> {
+ @Override
+ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ String formServiceRef = trimToNull(element.getAttribute("formServiceRef"));
+
+ if (formServiceRef != null) {
+ builder.addPropertyReference("formService", formServiceRef);
+ }
+ }
}
}
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:springext="http://www.alibaba.com/schema/springext/base" elementFormDefault="qualified">
<xsd:import namespace="http://www.springframework.org/schema/beans"
@@ -13,6 +12,7 @@
<xsd:complexType name="FormPullToolType">
<xsd:attributeGroup ref="springext:identifiedTypeAttributeSubset" />
+ <xsd:attribute name="formServiceRef" type="xsd:string" use="optional" />
</xsd:complexType>
</xsd:schema>
@@ -102,6 +102,7 @@
<pull>
<pull-tools:form-tool />
+ <pull-tools:form-tool id="tool5" formServiceRef="form5" />
</pull>
</beans:beans>
@@ -36,6 +36,7 @@
public class FormToolTests extends AbstractFormServiceTests {
private FormTool tool;
+ private FormTool tool5;
@BeforeClass
public static void initFactory() {
@@ -46,9 +47,13 @@ public static void initFactory() {
public void init() throws Exception {
getFormService("form1");
PullService pullService = (PullService) factory.getBean("pullService");
+
tool = (FormTool) pullService.getTools().get("form");
assertNotNull(tool);
+ tool5 = (FormTool) pullService.getTools().get("tool5");
+ assertNotNull(tool5);
+
newForm();
}
@@ -66,6 +71,17 @@ private void submitForm() throws Exception {
}
@Test
+ public void tool_formServiceRef() {
+ GroupInstanceHelper group1 = tool5.get("group1").getDefaultInstance();
+
+ assertNotNull(group1.get("field1"));
+ assertNotNull(group1.get("field2"));
+ assertNull(group1.get("field3"));
+
+ assertNull(tool5.get("group2").getDefaultInstance());
+ }
+
+ @Test
public void tool_toString() {
assertEquals("FormTool[no FormService]", new FormTool().toString());
assertEquals("form1:FormService {\n" //

0 comments on commit 0d9b2df

Please sign in to comment.