Hello,
 
I have a loop that creates a few forms and I have implemented the onValidate 
method to validate the input. If an error occours in the textarea of the first 
form, the textareas of all other forms are marked as erroneous too, although 
the forms and textareas have different IDs. Whats wrong?
 
Thanks in advance.
M.B.
 
 
Source code:
 
Index.java:
public class Index
{  
    @Property
    private int[] integers= { 1, 2, 3, 4, 5 };
    
    @Property
    private int anInteger;
    
    public Index()
    {
    }
}
 
Index.tml:
<html t:type="layout" title="HelloWorld Index" t:sidebarTitle="Framework 
Version" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"; 
xmlns:p="tapestry:parameter">
    <t:Loop t:source="integers" t:value="anInteger">
        <div>${anInteger}</div>
        <t:MyForm id="anInteger" />
    </t:Loop>
</html>
 
MyForm.java:

public class MyForm
{
    @Parameter(required=true)
    @Property
    private int id;
    
    @Property
    private String text;
    
    @InjectComponent
    private Form form;
    
    @InjectComponent
    private TextArea textarea;
    
    @Inject
    Logger logger;
    
    @Inject
    Messages messages;
    
    void onPrepareForSubmitFromForm(int id) {
        this.id = id;
    }
    public void onSuccess() {
        logger.info("onSuccess()");
    }
    
    void onValidateFromForm() {    
        logger.info("id: " + id);
        form.recordError(textarea, "Error");
    }
    
    public String getFormId() {
        return "form_" + id;
    }
    
    public String getTextareaId() {
        return "textarea_" + id;
    }
    
    public String getSubmitId() {
        return "submit_" + id;
    }
}
 
MyForm.tml:
 
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"; 
xmlns:p="tapestry:parameter">
    <t:form t:id="form" id="prop:formId" t:context="id" >
        <t:textarea t:id="textarea" id="prop:textareaId" value="text" rows="3" 
cols="50" />
        <t:submit t:id="submit" id="prop:submitId" class="btn btn-large 
btn-primary" value="Send" />
    </t:form>
</t:container>
 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to