Java

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Checkbox required validation not working

    2 answers - 2474 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I have tried out the suggestion in the post
    (*)
    to implement client side 'required' validation on a
    Checkbox compponent (in Tapestry 4.0.2).
    In (*), a validator with a custom javascript to
    validate a required checkbox was given.
    When I test it, the javascript does the validation
    never get rendered.
    After some debugging, I noticed that in the method
    renderComponent of Checkbox.java,
    it does not call
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    It is in the method
    getValidatableFieldSupport().renderContributions()
    that
    the javascript that does the validation is rendered.
    After adding
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    into the method renderComponent of Checkbox.java,
    the client side validation works.
    Also if I add
    renderDelegatePrefix(writer, cycle);
    and
    renderDelegateSuffix(writer, cycle);
    to the method renderComponent of Checkbox.java.
    the custom required validator also works when the
    validation is done on the server.
    Here is the modified renderComponent method of
    Checkbox.java :
    protected void renderFormComponent(IMarkupWriter
    writer, IRequestCycle cycle)
    {
    // New
    renderDelegatePrefix(writer, cycle);
    writer.beginEmpty("input");
    writer.attribute("type", "checkbox");
    writer.attribute("name", getName());
    if (isDisabled())
    writer.attribute("disabled", "disabled");
    if (getValue())
    writer.attribute("checked", "checked");
    renderIdAttribute(writer, cycle);
    // New
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    renderInformalParameters(writer, cycle);
    writer.closeTag();
    // New
    renderDelegateSuffix(writer, cycle);
    }
    Components like TextField and TextArea have
    renderDelegatePrefix(writer, cycle);
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    renderDelegateSuffix(writer, cycle)
    in their renderComponent methods.
    Shouldn't Checkbox be the same ?
    Shing
    Home page :
    The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider.
    To unsubscribe, e-mail: users-unsubscribe (AT) tapestry (DOT) apache.org
    For additional commands, e-mail: users-help (AT) tapestry (DOT) apache.org
  • No.1 | | 2704 bytes | |

    , nice catch! I've applied the changes and will deploy in next tapestry
    4.1 snapshot release later today.

    7/26/06, Shing Hing Man <matmsh (AT) yahoo (DOT) comwrote:

    I have tried out the suggestion in the post
    (*)

    to implement client side 'required' validation on a
    Checkbox compponent (in Tapestry 4.0.2).
    In (*), a validator with a custom javascript to
    validate a required checkbox was given.

    When I test it, the javascript does the validation
    never get rendered.
    After some debugging, I noticed that in the method
    renderComponent of Checkbox.java,
    it does not call

    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    --
    It is in the method
    getValidatableFieldSupport().renderContributions()
    that
    the javascript that does the validation is rendered.
    After adding
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    into the method renderComponent of Checkbox.java,
    the client side validation works.
    Also if I add

    renderDelegatePrefix(writer, cycle);
    and
    renderDelegateSuffix(writer, cycle);

    to the method renderComponent of Checkbox.java.
    the custom required validator also works when the
    validation is done on the server.

    Here is the modified renderComponent method of
    Checkbox.java :

    protected void renderFormComponent(IMarkupWriter
    writer, IRequestCycle cycle)
    {
    // New
    renderDelegatePrefix(writer, cycle);

    writer.beginEmpty("input");
    writer.attribute("type", "checkbox");

    writer.attribute("name", getName());

    if (isDisabled())
    writer.attribute("disabled", "disabled");

    if (getValue())
    writer.attribute("checked", "checked");

    renderIdAttribute(writer, cycle);

    // New

    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);

    renderInformalParameters(writer, cycle);

    writer.closeTag();
    // New
    renderDelegateSuffix(writer, cycle);
    }
    --
    Components like TextField and TextArea have
    renderDelegatePrefix(writer, cycle);
    --
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    renderDelegateSuffix(writer, cycle)

    in their renderComponent methods.
    Shouldn't Checkbox be the same ?

    Shing
    --
    Home page :

    >
    >
    >


    The all-new Yahoo! Mail goes wherever you go - free your email address
    from your Internet provider.

    To unsubscribe, e-mail: users-unsubscribe (AT) tapestry (DOT) apache.org
    For additional commands, e-mail: users-help (AT) tapestry (DOT) apache.org
    --
  • No.2 | | 3496 bytes | |

    MaybeRealistically, it's probably not going to happen anytime soon as
    tapestry 4.0.X is such a pain in the ass to deploy.

    The 4.1 snapshot build with the change is deploying via maven as I write
    this email.

    7/26/06, Shing Hing Man <matmsh (AT) yahoo (DOT) comwrote:
    --
    Any chance of doing to Tapestry 4.0.2 as well ?

    Shing

    Jesse Kuhnert <jkuhnert (AT) gmail (DOT) comwrote:

    , nice catch! I've applied the changes and will
    deploy in next tapestry
    4.1 snapshot release later today.

    7/26/06, Shing Hing Man <matmsh (AT) yahoo (DOT) comwrote:

    I have tried out the suggestion in the post
    (*)
    >
    >
    >
    >


    to implement client side 'required' validation on
    a
    Checkbox compponent (in Tapestry 4.0.2).
    In (*), a validator with a custom javascript to
    validate a required checkbox was given.

    When I test it, the javascript does the
    validation
    never get rendered.
    After some debugging, I noticed that in the method
    renderComponent of Checkbox.java,
    it does not call
    >
    >
    >

    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    --
    It is in the method
    getValidatableFieldSupport().renderContributions()
    that
    the javascript that does the validation is
    rendered.
    After adding
    --
    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    into the method renderComponent of
    Checkbox.java,
    the client side validation works.
    Also if I add

    renderDelegatePrefix(writer, cycle);
    and
    renderDelegateSuffix(writer, cycle);

    to the method renderComponent of Checkbox.java.
    the custom required validator also works when the
    validation is done on the server.

    Here is the modified renderComponent method of
    Checkbox.java :

    protected void renderFormComponent(IMarkupWriter
    writer, IRequestCycle cycle)
    {
    // New
    renderDelegatePrefix(writer, cycle);

    writer.beginEmpty("input");
    writer.attribute("type", "checkbox");

    writer.attribute("name", getName());

    if (isDisabled())
    writer.attribute("disabled",
    "disabled");

    if (getValue())
    writer.attribute("checked",
    "checked");

    renderIdAttribute(writer, cycle);

    // New
    >
    >
    >

    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);

    renderInformalParameters(writer, cycle);

    writer.closeTag();
    // New
    renderDelegateSuffix(writer, cycle);
    }
    --
    Components like TextField and TextArea have
    renderDelegatePrefix(writer, cycle);
    >
    >
    >
    >

    getValidatableFieldSupport().renderContributions(t his,
    writer, cycle);
    renderDelegateSuffix(writer, cycle)

    in their renderComponent methods.
    Shouldn't Checkbox be the same ?

    Shing
    --
    Home page :

    >
    >
    >
    >
    >


    The all-new Yahoo! Mail goes wherever you go -
    free your email address
    from your Internet provider.

    >
    >
    >


    To unsubscribe, e-mail:
    users-unsubscribe (AT) tapestry (DOT) apache.org
    For additional commands, e-mail:
    users-help (AT) tapestry (DOT) apache.org
    >
    >
    >
    >

Re: Checkbox required validation not working


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "Java"

EMSDN.COM