[
https://issues.apache.org/jira/browse/TAP5-1981?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jochen Kemnade updated TAP5-1981:
---------------------------------
Description:
Here is example.
Let's admit is bean with a property "number" which value should not be greater
than 2.
There are 2 forms with RadioGroup.
The first form uses tapestry validation, The second - JSR-303.
If you will choose "3" and will submit the first form - validation will not
work.
If you will choose "3" and will submit the second form that there will be an
exception.
{code}
package com.mycompany.mavenproject1.entities;
import javax.validation.constraints.Max;
/**
*
* @author AlexLumpov
*/
public class Bean {
private int number;
@Max(2)
public int getNumber() {
return number;
}
public void setNumber(int value) {
number = value;
}
}
{code}
{code}
package com.mycompany.mavenproject1.pages;
import com.mycompany.mavenproject1.entities.Bean;
import org.apache.tapestry5.FieldValidator;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.corelib.components.RadioGroup;
import org.apache.tapestry5.services.PropertyEditContext;
/**
* Start page of application mavenproject1.
*/
public class Index {
@Component(parameters = {"value=bean.number",
"validate=prop:beanValidator"})
private RadioGroup group2;
/* */
@Persist
private Bean bean;
/* */
@Environmental
private PropertyEditContext context;
public Bean getBean() {
if (bean == null)
bean = new Bean();
return bean;
}
public FieldValidator getBeanValidator() {
return context.getValidator(group2);
}
}
{code}
{code}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>RadioGroup Validation Test</title>
</head>
<body>
<h1>test 1</h1>
<t:form>
<t:errors/>
<t:RadioGroup value="bean.number" validate="max=2">
<t:radio value="1"/>1<br/>
<t:radio value="2"/>2<br/>
<t:radio value="3"/>3<br/>
</t:RadioGroup>
<t:submit/>
</t:form>
<h1>test 2</h1>
<t:BeanEditForm object="bean">
<p:number>
<t:comp t:id="group2">
<t:radio value="1"/>1<br/>
<t:radio value="2"/>2<br/>
<t:radio value="3"/>3<br/>
</t:comp>
</p:number>
</t:BeanEditForm>
</body>
</html>
{code}
was:
Here is example.
Let's admit is bean with a property "number" which value should not be greater
than 2.
There are 2 forms with RadioGroup.
The first form uses tapestry validation, The second - JSR-303.
If you will choose "3" and will submit the first form - validation will not
work.
If you will choose "3" and will submit the second form that there will be an
exception.
package com.mycompany.mavenproject1.entities;
import javax.validation.constraints.Max;
/**
*
* @author AlexLumpov
*/
public class Bean {
private int number;
@Max(2)
public int getNumber() {
return number;
}
public void setNumber(int value) {
number = value;
}
}
package com.mycompany.mavenproject1.pages;
import com.mycompany.mavenproject1.entities.Bean;
import org.apache.tapestry5.FieldValidator;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.corelib.components.RadioGroup;
import org.apache.tapestry5.services.PropertyEditContext;
/**
* Start page of application mavenproject1.
*/
public class Index {
@Component(parameters = {"value=bean.number",
"validate=prop:beanValidator"})
private RadioGroup group2;
/* */
@Persist
private Bean bean;
/* */
@Environmental
private PropertyEditContext context;
public Bean getBean() {
if (bean == null)
bean = new Bean();
return bean;
}
public FieldValidator getBeanValidator() {
return context.getValidator(group2);
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>RadioGroup Validation Test</title>
</head>
<body>
<h1>test 1</h1>
<t:form>
<t:errors/>
<t:RadioGroup value="bean.number" validate="max=2">
<t:radio value="1"/>1<br/>
<t:radio value="2"/>2<br/>
<t:radio value="3"/>3<br/>
</t:RadioGroup>
<t:submit/>
</t:form>
<h1>test 2</h1>
<t:BeanEditForm object="bean">
<p:number>
<t:comp t:id="group2">
<t:radio value="1"/>1<br/>
<t:radio value="2"/>2<br/>
<t:radio value="3"/>3<br/>
</t:comp>
</p:number>
</t:BeanEditForm>
</body>
</html>
> RadioGroup component validation error
> -------------------------------------
>
> Key: TAP5-1981
> URL: https://issues.apache.org/jira/browse/TAP5-1981
> Project: Tapestry 5
> Issue Type: Bug
> Components: tapestry-core
> Affects Versions: 5.3.4
> Reporter: Alex Lumpov
> Labels: patch
> Attachments: RadioGroup.java.patch, mavenproject1.zip
>
>
> Here is example.
> Let's admit is bean with a property "number" which value should not be
> greater than 2.
> There are 2 forms with RadioGroup.
> The first form uses tapestry validation, The second - JSR-303.
> If you will choose "3" and will submit the first form - validation will not
> work.
> If you will choose "3" and will submit the second form that there will be an
> exception.
> {code}
> package com.mycompany.mavenproject1.entities;
> import javax.validation.constraints.Max;
> /**
> *
> * @author AlexLumpov
> */
> public class Bean {
> private int number;
> @Max(2)
> public int getNumber() {
> return number;
> }
> public void setNumber(int value) {
> number = value;
> }
> }
> {code}
> {code}
> package com.mycompany.mavenproject1.pages;
> import com.mycompany.mavenproject1.entities.Bean;
> import org.apache.tapestry5.FieldValidator;
> import org.apache.tapestry5.annotations.Component;
> import org.apache.tapestry5.annotations.Environmental;
> import org.apache.tapestry5.annotations.Persist;
> import org.apache.tapestry5.corelib.components.RadioGroup;
> import org.apache.tapestry5.services.PropertyEditContext;
> /**
> * Start page of application mavenproject1.
> */
> public class Index {
> @Component(parameters = {"value=bean.number",
> "validate=prop:beanValidator"})
> private RadioGroup group2;
> /* */
> @Persist
> private Bean bean;
> /* */
> @Environmental
> private PropertyEditContext context;
> public Bean getBean() {
> if (bean == null)
> bean = new Bean();
> return bean;
> }
> public FieldValidator getBeanValidator() {
> return context.getValidator(group2);
> }
> }
> {code}
> {code}
> <!DOCTYPE html>
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
> xmlns:p="tapestry:parameter">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
> <title>RadioGroup Validation Test</title>
> </head>
> <body>
> <h1>test 1</h1>
> <t:form>
> <t:errors/>
> <t:RadioGroup value="bean.number" validate="max=2">
> <t:radio value="1"/>1<br/>
> <t:radio value="2"/>2<br/>
> <t:radio value="3"/>3<br/>
> </t:RadioGroup>
> <t:submit/>
> </t:form>
> <h1>test 2</h1>
> <t:BeanEditForm object="bean">
> <p:number>
> <t:comp t:id="group2">
> <t:radio value="1"/>1<br/>
> <t:radio value="2"/>2<br/>
> <t:radio value="3"/>3<br/>
> </t:comp>
> </p:number>
> </t:BeanEditForm>
> </body>
> </html>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)