I want to create a subform with tapestry5:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<t:TextField t:id="name" />
</html>
and use it like this:
<form t:type="form" t:id="testForm">
<t:testComponent name="name" />
<input type="submit"/>
</form>
TestComponent.java:
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
public class TestComponent {
@Parameter(required = true, allowNull = false)
@Property
private String name;
}
so that i can use the value of 'name' like:
@Property
private String name;
void onSuccessFromTestForm() {
System.out.println(name);
}
But all i get is an application exception:
Render queue error in BeginRender[Index:testcomponent.name]: Failure reading parameter 'value' of component Index:testcomponent.name: Parameter 'name' of component Index:testcomponent is bound to null. This parameter is not allowed to be null.
Whats the problem?
Tapestry is telling you that the component containing your
Form
and yourTestComponent
has a property "name" with value null. So you problem is not in yourTestComponent
, but one component/page higher. Assign a value to name and you should be good.Edit
If you mean to allow people to assign a value though your form and allow null values while rendering the page, remove the
allowNull = false
from your@Parameter
in yourTestComponent
. I'm assuming you want to force the user to provide a value for the name field before submitting the form. This is done on the input field by adding thet:validate="required"
attribute, not on the@Parameter
. The@Parameter
tells tapestry how the instance variable interacts with its container, it sais nothing about how the variable is used within its own component.