Thiago thanks for reponding. Here is the java code

  public class FieldValidationErrorMsg {

    @Parameter(required = true, defaultPrefix="literal")
    private String fieldId;

    @Parameter
    private Form form;

    @Parameter
    private Boolean leaveMessage;

    @Parameter (defaultPrefix="literal")
    private String errorId;

    @Parameter (defaultPrefix="literal")
    private String labelId;

    @Environmental(false)
    private ValidationTracker tracker;

    public void setFieldId(String fieldId) {
        this.fieldId = fieldId;
    }
    public String getFieldId() {
        return this.fieldId;
    }
    public String getLabelId() {
        return this.labelId;
    }
    public void setForm(Form form) {
        this.form = form;
    }

    public void afterRenderBody(MarkupWriter writer) {
        final String _fieldId = this.fieldId;
        Field f = new Field() {
            public String getLabel() { return null; }
            public boolean isDisabled() { return false; }
            public String getClientId() { return _fieldId; }
            public String getControlName() { return _fieldId; }
            public boolean isRequired() { return false; }
        };

        // grab the FieldValidationErrorMsg component
        Element msgEle = writer.getElement();

        ValidationTracker tracker;
        if ( this.form != null ) {
            tracker = this.form.getDefaultTracker();
        } else {
            tracker = this.tracker;
        }

        if ( (this.errorId != null && tracker.getError(f) != null &&
tracker.getError(f).contains(this.errorId))
             || (this.errorId == null && tracker.inError(f)) ) {
            // we need to display the error message, so do nothing, leave
it as is
        } else {
            // remove the error message, unless there's an instruction to
leave it in place
            if (this.leaveMessage==null || !this.leaveMessage) {
                msgEle.removeChildren();
                msgEle.pop();
            } else {
                // we're leaving it in place, but will hide it on page load
by adding a class "hidden"
                String curClassValue = msgEle.getAttribute("class");
                String[] classValues = {"class","hidden "+curClassValue};
                msgEle.forceAttributes(classValues);
            }
        }
    }

}

and FieldValidationErrorMsg tml is

<?xml version="1.0" encoding="UTF-8"?>
<label for="${fieldId}" class="error" generated="false" xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:if test="labelId">
        <t:sh.common.addAttribute name="id" value="${labelId}"/>
    </t:if>
    <t:body />
</label>


>From whers its being called is Login.tml

    <div class="input clear">
                    <label
for="loginEmail">${msg:common.formElement.Email}</label>
                    <input name="loginEmail" t:id="loginEmail"
t:type="TextField" t:value="loginModel.loginEmail" />
                    <label t:type="sh/common/FieldValidationErrorMsg"
t:fieldId="loginEmail"
t:errorId="requiredFieldIsMissing">${msg:common.formElement.EnterValidEmail}</label>
                </div>


Thanks,
Rukmini


On Fri, Aug 30, 2013 at 2:28 PM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Fri, 30 Aug 2013 18:05:33 -0300, rukmini n <rukmini...@gmail.com>
> wrote:
>
>  Hi All,
>>
>
> Hi!
>
>
>  Any one knows, what might be issue here. I'm still stuck. Please help..
>>
>
> The error itself happens at com.test.ui.components.sh.**common.**
> FieldValidationErrorMsg.**afterRenderBody, so we need its source to help
> you.
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to