You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ryan Norris <ry...@gmail.com> on 2009/04/29 03:53:15 UTC

Updating a Label in a Form using AjaxFormComponentUpdatingBehavior

I've been struggling for a while now fighting with
AjaxFormComponentUpdatingBehavior and changing the value of a label
within form when a certain javascript precondition is met.

Code below.

    public final class RegistrationForm extends Form<Registration> {
        private static final long serialVersionUID = 1L;

        private Registration _registration = new Registration();
        private CityState _cityState = new CityState();

        public RegistrationForm(String id) {
            super(id);

            add(new TextField<String>("emailAddress", new
PropertyModel<String>(_registration, "emailAddress")));
            add(new PasswordTextField("password", new
PropertyModel<String>(_registration, "password")));
            add(new TextField<String>("firstName", new
PropertyModel<String>(_registration, "firstName")));
            add(new TextField<String>("lastName", new
PropertyModel<String>(_registration, "lastName")));
            add(new TextField<String>("address1", new
PropertyModel<String>(_registration, "address1")));
            add(new TextField<String>("address2", new
PropertyModel<String>(_registration, "address2")));
            add(new TextField<String>("establishmentName", new
PropertyModel<String>(_registration, "establishmentName")));

            final Label cityStateLabel = new Label("cityState", new
PropertyModel<String>(_cityState, "city"));
            cityStateLabel.setOutputMarkupId(true);

            final TextField<String> zipCodeField = new
TextField<String>("zip", new PropertyModel<String>(_registration,
"postalCode"));

            zipCodeField.add(new AjaxFormComponentUpdatingBehavior("onKeyUp") {
                private static final long serialVersionUID = 1L;

                @Override
                protected CharSequence getPreconditionScript() {
                    return "return $(\"input[name='zip']\").val().length == 5;";
                }

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    if(target != null) {
                        _log.info(String.format("Looking up postal
code: %1$s", _registration.getPostalCode()));

                        PostalCode pc =
_postalCodeManager.getLocaleDataForCode(_registration.getPostalCode());

                        _cityState.setCity(pc.getCity());
                        _cityState.setState(pc.getState());

                        target.addComponent(cityStateLabel);
                    }
                }
            });

            add(zipCodeField);
            add(cityStateLabel);
        }

        @Override
        protected void onSubmit() {
            try {

_accountManager.createAccount(_registration.getEmailAddress(),
_registration.getPassword());
            } catch (DuplicateEmailAddressException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

The general gist is to display the city for a given input of 5
characters.  The error I'm getting is completely unrelated...

exception

org.apache.wicket.WicketRuntimeException: Internal Error: Could not
render error page class
org.apache.wicket.markup.html.pages.InternalErrorPage
	org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:174)
	org.apache.wicket.RequestCycle.step(RequestCycle.java:1321)
	org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
	org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
	org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
	org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)

root cause

org.apache.wicket.markup.MarkupException: Tag '<DT>' (line 101, column
1) has a mismatched close tag at '</DL>' (line 102, column 1)
[markup = jar:file:/C:/Documents%20and%20Settings/rnorris/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web/WEB-INF/lib/wicket-1.4-rc2-javadoc.jar!/org/apache/wicket/markup/html/pages/ExceptionErrorPage.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


<!--NewPage-->

So, aside from the exception being pretty useless - debugging things
gets me pretty deep in the weeds.  Before I go through the trouble of
filing a JIRA ticket, can anyone tell me:

1.  Is what I'm doing a covered use case (update a label in a form as
a result of a AjaxFormComponentUpdatingBehavior event)?
2.  Is my approach expected to work?  From the scattered documentation
I've found, this looks completely feasible.
3.  Are there any known issues with the rendering and handling of
Errors in 1.4-rc2?  This isn't the first time I've encountered some
really difficult to debug problems, but the fact that this is in an
AJAX scenario makes this really painful.

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Updating a Label in a Form using AjaxFormComponentUpdatingBehavior

Posted by Randy Hammelman <ra...@gmail.com>.
I didn't look at your code in detail line by line, but the concept should
work. I do similar things all the time.

Try setting your own error page to determine if this is an error with the
error page or a very weird error with your code.

You can also try using the debugger to find the exception that is triggering
the error page.

Hope this helped.

Randy

On Tue, Apr 28, 2009 at 8:53 PM, Ryan Norris <ry...@gmail.com> wrote:

> I've been struggling for a while now fighting with
> AjaxFormComponentUpdatingBehavior and changing the value of a label
> within form when a certain javascript precondition is met.
>
> Code below.
>
>     public final class RegistrationForm extends Form<Registration> {
>         private static final long serialVersionUID = 1L;
>
>         private Registration _registration = new Registration();
>         private CityState _cityState = new CityState();
>
>         public RegistrationForm(String id) {
>             super(id);
>
>             add(new TextField<String>("emailAddress", new
> PropertyModel<String>(_registration, "emailAddress")));
>             add(new PasswordTextField("password", new
> PropertyModel<String>(_registration, "password")));
>             add(new TextField<String>("firstName", new
> PropertyModel<String>(_registration, "firstName")));
>             add(new TextField<String>("lastName", new
> PropertyModel<String>(_registration, "lastName")));
>             add(new TextField<String>("address1", new
> PropertyModel<String>(_registration, "address1")));
>             add(new TextField<String>("address2", new
> PropertyModel<String>(_registration, "address2")));
>             add(new TextField<String>("establishmentName", new
> PropertyModel<String>(_registration, "establishmentName")));
>
>             final Label cityStateLabel = new Label("cityState", new
> PropertyModel<String>(_cityState, "city"));
>             cityStateLabel.setOutputMarkupId(true);
>
>             final TextField<String> zipCodeField = new
> TextField<String>("zip", new PropertyModel<String>(_registration,
> "postalCode"));
>
>             zipCodeField.add(new
> AjaxFormComponentUpdatingBehavior("onKeyUp") {
>                 private static final long serialVersionUID = 1L;
>
>                 @Override
>                 protected CharSequence getPreconditionScript() {
>                     return "return $(\"input[name='zip']\").val().length ==
> 5;";
>                 }
>
>                 @Override
>                 protected void onUpdate(AjaxRequestTarget target) {
>                     if(target != null) {
>                         _log.info(String.format("Looking up postal
> code: %1$s", _registration.getPostalCode()));
>
>                         PostalCode pc =
> _postalCodeManager.getLocaleDataForCode(_registration.getPostalCode());
>
>                         _cityState.setCity(pc.getCity());
>                         _cityState.setState(pc.getState());
>
>                         target.addComponent(cityStateLabel);
>                     }
>                 }
>             });
>
>             add(zipCodeField);
>             add(cityStateLabel);
>         }
>
>         @Override
>         protected void onSubmit() {
>             try {
>
> _accountManager.createAccount(_registration.getEmailAddress(),
> _registration.getPassword());
>             } catch (DuplicateEmailAddressException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>         }
>     }
>
> The general gist is to display the city for a given input of 5
> characters.  The error I'm getting is completely unrelated...
>
> exception
>
> org.apache.wicket.WicketRuntimeException: Internal Error: Could not
> render error page class
> org.apache.wicket.markup.html.pages.InternalErrorPage
>
>  org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:174)
>        org.apache.wicket.RequestCycle.step(RequestCycle.java:1321)
>        org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
>        org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
>
>  org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
>
>  org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
>
> root cause
>
> org.apache.wicket.markup.MarkupException: Tag '<DT>' (line 101, column
> 1) has a mismatched close tag at '</DL>' (line 102, column 1)
> [markup =
> jar:file:/C:/Documents%20and%20Settings/rnorris/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web/WEB-INF/lib/wicket-1.4-rc2-javadoc.jar!/org/apache/wicket/markup/html/pages/ExceptionErrorPage.html
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
>
>
> <!--NewPage-->
>
> So, aside from the exception being pretty useless - debugging things
> gets me pretty deep in the weeds.  Before I go through the trouble of
> filing a JIRA ticket, can anyone tell me:
>
> 1.  Is what I'm doing a covered use case (update a label in a form as
> a result of a AjaxFormComponentUpdatingBehavior event)?
> 2.  Is my approach expected to work?  From the scattered documentation
> I've found, this looks completely feasible.
> 3.  Are there any known issues with the rendering and handling of
> Errors in 1.4-rc2?  This isn't the first time I've encountered some
> really difficult to debug problems, but the fact that this is in an
> AJAX scenario makes this really painful.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Randy Hammelman
512-657-8950

Re: Updating a Label in a Form using AjaxFormComponentUpdatingBehavior

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Yes - I hate m2eclipse.  I just run mvn eclipse:eclipse from the
command line and refresh my sources in Eclipse.  Add the
-DdownloadSources=true and -DdownloadJavadocs=true - it works great.

--
Jeremy Thomerson
http://www.wickettraining.com




On Wed, Apr 29, 2009 at 5:26 AM, Ryan Norris <ry...@gmail.com> wrote:
> Wow.  Nice catch.
>
> Lesson learned - be cautious with the m2eclipse plugin and the WTP when
> attching Javadocs to the library.
>
> Thanks.
>
> On Apr 28, 2009, at 10:55 PM, Jeremy Thomerson wrote:
>
>> You have the javadocs jar in your classpath.  It shouldn't be.  That
>> should fix the error page so that you can see your error (which should
>> also be visible in the logs anyway).
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>>
>>
>> On Tue, Apr 28, 2009 at 8:53 PM, Ryan Norris <ry...@gmail.com> wrote:
>>>
>>> I've been struggling for a while now fighting with
>>> AjaxFormComponentUpdatingBehavior and changing the value of a label
>>> within form when a certain javascript precondition is met.
>>>
>>> Code below.
>>>
>>>    public final class RegistrationForm extends Form<Registration> {
>>>        private static final long serialVersionUID = 1L;
>>>
>>>        private Registration _registration = new Registration();
>>>        private CityState _cityState = new CityState();
>>>
>>>        public RegistrationForm(String id) {
>>>            super(id);
>>>
>>>            add(new TextField<String>("emailAddress", new
>>> PropertyModel<String>(_registration, "emailAddress")));
>>>            add(new PasswordTextField("password", new
>>> PropertyModel<String>(_registration, "password")));
>>>            add(new TextField<String>("firstName", new
>>> PropertyModel<String>(_registration, "firstName")));
>>>            add(new TextField<String>("lastName", new
>>> PropertyModel<String>(_registration, "lastName")));
>>>            add(new TextField<String>("address1", new
>>> PropertyModel<String>(_registration, "address1")));
>>>            add(new TextField<String>("address2", new
>>> PropertyModel<String>(_registration, "address2")));
>>>            add(new TextField<String>("establishmentName", new
>>> PropertyModel<String>(_registration, "establishmentName")));
>>>
>>>            final Label cityStateLabel = new Label("cityState", new
>>> PropertyModel<String>(_cityState, "city"));
>>>            cityStateLabel.setOutputMarkupId(true);
>>>
>>>            final TextField<String> zipCodeField = new
>>> TextField<String>("zip", new PropertyModel<String>(_registration,
>>> "postalCode"));
>>>
>>>            zipCodeField.add(new
>>> AjaxFormComponentUpdatingBehavior("onKeyUp") {
>>>                private static final long serialVersionUID = 1L;
>>>
>>>                @Override
>>>                protected CharSequence getPreconditionScript() {
>>>                    return "return $(\"input[name='zip']\").val().length
>>> == 5;";
>>>                }
>>>
>>>                @Override
>>>                protected void onUpdate(AjaxRequestTarget target) {
>>>                    if(target != null) {
>>>                        _log.info(String.format("Looking up postal
>>> code: %1$s", _registration.getPostalCode()));
>>>
>>>                        PostalCode pc =
>>> _postalCodeManager.getLocaleDataForCode(_registration.getPostalCode());
>>>
>>>                        _cityState.setCity(pc.getCity());
>>>                        _cityState.setState(pc.getState());
>>>
>>>                        target.addComponent(cityStateLabel);
>>>                    }
>>>                }
>>>            });
>>>
>>>            add(zipCodeField);
>>>            add(cityStateLabel);
>>>        }
>>>
>>>        @Override
>>>        protected void onSubmit() {
>>>            try {
>>>
>>> _accountManager.createAccount(_registration.getEmailAddress(),
>>> _registration.getPassword());
>>>            } catch (DuplicateEmailAddressException e) {
>>>                // TODO Auto-generated catch block
>>>                e.printStackTrace();
>>>            }
>>>        }
>>>    }
>>>
>>> The general gist is to display the city for a given input of 5
>>> characters.  The error I'm getting is completely unrelated...
>>>
>>> exception
>>>
>>> org.apache.wicket.WicketRuntimeException: Internal Error: Could not
>>> render error page class
>>> org.apache.wicket.markup.html.pages.InternalErrorPage
>>>
>>> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:174)
>>>       org.apache.wicket.RequestCycle.step(RequestCycle.java:1321)
>>>       org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
>>>       org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
>>>
>>> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
>>>
>>> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
>>>
>>> root cause
>>>
>>> org.apache.wicket.markup.MarkupException: Tag '<DT>' (line 101, column
>>> 1) has a mismatched close tag at '</DL>' (line 102, column 1)
>>> [markup =
>>> jar:file:/C:/Documents%20and%20Settings/rnorris/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web/WEB-INF/lib/wicket-1.4-rc2-javadoc.jar!/org/apache/wicket/markup/html/pages/ExceptionErrorPage.html
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>
>>>
>>> <!--NewPage-->
>>>
>>> So, aside from the exception being pretty useless - debugging things
>>> gets me pretty deep in the weeds.  Before I go through the trouble of
>>> filing a JIRA ticket, can anyone tell me:
>>>
>>> 1.  Is what I'm doing a covered use case (update a label in a form as
>>> a result of a AjaxFormComponentUpdatingBehavior event)?
>>> 2.  Is my approach expected to work?  From the scattered documentation
>>> I've found, this looks completely feasible.
>>> 3.  Are there any known issues with the rendering and handling of
>>> Errors in 1.4-rc2?  This isn't the first time I've encountered some
>>> really difficult to debug problems, but the fact that this is in an
>>> AJAX scenario makes this really painful.
>>>
>>> Thanks.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Updating a Label in a Form using AjaxFormComponentUpdatingBehavior

Posted by Ryan Norris <ry...@gmail.com>.
Wow.  Nice catch.

Lesson learned - be cautious with the m2eclipse plugin and the WTP  
when attching Javadocs to the library.

Thanks.

On Apr 28, 2009, at 10:55 PM, Jeremy Thomerson wrote:

> You have the javadocs jar in your classpath.  It shouldn't be.  That
> should fix the error page so that you can see your error (which should
> also be visible in the logs anyway).
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
>
> On Tue, Apr 28, 2009 at 8:53 PM, Ryan Norris <ry...@gmail.com>  
> wrote:
>> I've been struggling for a while now fighting with
>> AjaxFormComponentUpdatingBehavior and changing the value of a label
>> within form when a certain javascript precondition is met.
>>
>> Code below.
>>
>>     public final class RegistrationForm extends Form<Registration> {
>>         private static final long serialVersionUID = 1L;
>>
>>         private Registration _registration = new Registration();
>>         private CityState _cityState = new CityState();
>>
>>         public RegistrationForm(String id) {
>>             super(id);
>>
>>             add(new TextField<String>("emailAddress", new
>> PropertyModel<String>(_registration, "emailAddress")));
>>             add(new PasswordTextField("password", new
>> PropertyModel<String>(_registration, "password")));
>>             add(new TextField<String>("firstName", new
>> PropertyModel<String>(_registration, "firstName")));
>>             add(new TextField<String>("lastName", new
>> PropertyModel<String>(_registration, "lastName")));
>>             add(new TextField<String>("address1", new
>> PropertyModel<String>(_registration, "address1")));
>>             add(new TextField<String>("address2", new
>> PropertyModel<String>(_registration, "address2")));
>>             add(new TextField<String>("establishmentName", new
>> PropertyModel<String>(_registration, "establishmentName")));
>>
>>             final Label cityStateLabel = new Label("cityState", new
>> PropertyModel<String>(_cityState, "city"));
>>             cityStateLabel.setOutputMarkupId(true);
>>
>>             final TextField<String> zipCodeField = new
>> TextField<String>("zip", new PropertyModel<String>(_registration,
>> "postalCode"));
>>
>>             zipCodeField.add(new  
>> AjaxFormComponentUpdatingBehavior("onKeyUp") {
>>                 private static final long serialVersionUID = 1L;
>>
>>                 @Override
>>                 protected CharSequence getPreconditionScript() {
>>                     return "return $(\"input[name='zip'] 
>> \").val().length == 5;";
>>                 }
>>
>>                 @Override
>>                 protected void onUpdate(AjaxRequestTarget target) {
>>                     if(target != null) {
>>                         _log.info(String.format("Looking up postal
>> code: %1$s", _registration.getPostalCode()));
>>
>>                         PostalCode pc =
>> _postalCodeManager 
>> .getLocaleDataForCode(_registration.getPostalCode());
>>
>>                         _cityState.setCity(pc.getCity());
>>                         _cityState.setState(pc.getState());
>>
>>                         target.addComponent(cityStateLabel);
>>                     }
>>                 }
>>             });
>>
>>             add(zipCodeField);
>>             add(cityStateLabel);
>>         }
>>
>>         @Override
>>         protected void onSubmit() {
>>             try {
>>
>> _accountManager.createAccount(_registration.getEmailAddress(),
>> _registration.getPassword());
>>             } catch (DuplicateEmailAddressException e) {
>>                 // TODO Auto-generated catch block
>>                 e.printStackTrace();
>>             }
>>         }
>>     }
>>
>> The general gist is to display the city for a given input of 5
>> characters.  The error I'm getting is completely unrelated...
>>
>> exception
>>
>> org.apache.wicket.WicketRuntimeException: Internal Error: Could not
>> render error page class
>> org.apache.wicket.markup.html.pages.InternalErrorPage
>>         
>> org 
>> .apache 
>> .wicket 
>> .request 
>> .AbstractRequestCycleProcessor 
>> .respond(AbstractRequestCycleProcessor.java:174)
>>        org.apache.wicket.RequestCycle.step(RequestCycle.java:1321)
>>        org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
>>        org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
>>         
>> org 
>> .apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java: 
>> 455)
>>         
>> org 
>> .apache 
>> .wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
>>
>> root cause
>>
>> org.apache.wicket.markup.MarkupException: Tag '<DT>' (line 101,  
>> column
>> 1) has a mismatched close tag at '</DL>' (line 102, column 1)
>> [markup = jar:file:/C:/Documents%20and%20Settings/rnorris/ 
>> workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/ 
>> wtpwebapps/web/WEB-INF/lib/wicket-1.4-rc2-javadoc.jar!/org/apache/ 
>> wicket/markup/html/pages/ExceptionErrorPage.html
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>>
>>
>> <!--NewPage-->
>>
>> So, aside from the exception being pretty useless - debugging things
>> gets me pretty deep in the weeds.  Before I go through the trouble of
>> filing a JIRA ticket, can anyone tell me:
>>
>> 1.  Is what I'm doing a covered use case (update a label in a form as
>> a result of a AjaxFormComponentUpdatingBehavior event)?
>> 2.  Is my approach expected to work?  From the scattered  
>> documentation
>> I've found, this looks completely feasible.
>> 3.  Are there any known issues with the rendering and handling of
>> Errors in 1.4-rc2?  This isn't the first time I've encountered some
>> really difficult to debug problems, but the fact that this is in an
>> AJAX scenario makes this really painful.
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Updating a Label in a Form using AjaxFormComponentUpdatingBehavior

Posted by Jeremy Thomerson <je...@wickettraining.com>.
You have the javadocs jar in your classpath.  It shouldn't be.  That
should fix the error page so that you can see your error (which should
also be visible in the logs anyway).

--
Jeremy Thomerson
http://www.wickettraining.com




On Tue, Apr 28, 2009 at 8:53 PM, Ryan Norris <ry...@gmail.com> wrote:
> I've been struggling for a while now fighting with
> AjaxFormComponentUpdatingBehavior and changing the value of a label
> within form when a certain javascript precondition is met.
>
> Code below.
>
>     public final class RegistrationForm extends Form<Registration> {
>         private static final long serialVersionUID = 1L;
>
>         private Registration _registration = new Registration();
>         private CityState _cityState = new CityState();
>
>         public RegistrationForm(String id) {
>             super(id);
>
>             add(new TextField<String>("emailAddress", new
> PropertyModel<String>(_registration, "emailAddress")));
>             add(new PasswordTextField("password", new
> PropertyModel<String>(_registration, "password")));
>             add(new TextField<String>("firstName", new
> PropertyModel<String>(_registration, "firstName")));
>             add(new TextField<String>("lastName", new
> PropertyModel<String>(_registration, "lastName")));
>             add(new TextField<String>("address1", new
> PropertyModel<String>(_registration, "address1")));
>             add(new TextField<String>("address2", new
> PropertyModel<String>(_registration, "address2")));
>             add(new TextField<String>("establishmentName", new
> PropertyModel<String>(_registration, "establishmentName")));
>
>             final Label cityStateLabel = new Label("cityState", new
> PropertyModel<String>(_cityState, "city"));
>             cityStateLabel.setOutputMarkupId(true);
>
>             final TextField<String> zipCodeField = new
> TextField<String>("zip", new PropertyModel<String>(_registration,
> "postalCode"));
>
>             zipCodeField.add(new AjaxFormComponentUpdatingBehavior("onKeyUp") {
>                 private static final long serialVersionUID = 1L;
>
>                 @Override
>                 protected CharSequence getPreconditionScript() {
>                     return "return $(\"input[name='zip']\").val().length == 5;";
>                 }
>
>                 @Override
>                 protected void onUpdate(AjaxRequestTarget target) {
>                     if(target != null) {
>                         _log.info(String.format("Looking up postal
> code: %1$s", _registration.getPostalCode()));
>
>                         PostalCode pc =
> _postalCodeManager.getLocaleDataForCode(_registration.getPostalCode());
>
>                         _cityState.setCity(pc.getCity());
>                         _cityState.setState(pc.getState());
>
>                         target.addComponent(cityStateLabel);
>                     }
>                 }
>             });
>
>             add(zipCodeField);
>             add(cityStateLabel);
>         }
>
>         @Override
>         protected void onSubmit() {
>             try {
>
> _accountManager.createAccount(_registration.getEmailAddress(),
> _registration.getPassword());
>             } catch (DuplicateEmailAddressException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>         }
>     }
>
> The general gist is to display the city for a given input of 5
> characters.  The error I'm getting is completely unrelated...
>
> exception
>
> org.apache.wicket.WicketRuntimeException: Internal Error: Could not
> render error page class
> org.apache.wicket.markup.html.pages.InternalErrorPage
>        org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:174)
>        org.apache.wicket.RequestCycle.step(RequestCycle.java:1321)
>        org.apache.wicket.RequestCycle.steps(RequestCycle.java:1370)
>        org.apache.wicket.RequestCycle.request(RequestCycle.java:501)
>        org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:455)
>        org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:288)
>
> root cause
>
> org.apache.wicket.markup.MarkupException: Tag '<DT>' (line 101, column
> 1) has a mismatched close tag at '</DL>' (line 102, column 1)
> [markup = jar:file:/C:/Documents%20and%20Settings/rnorris/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web/WEB-INF/lib/wicket-1.4-rc2-javadoc.jar!/org/apache/wicket/markup/html/pages/ExceptionErrorPage.html
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
>
>
> <!--NewPage-->
>
> So, aside from the exception being pretty useless - debugging things
> gets me pretty deep in the weeds.  Before I go through the trouble of
> filing a JIRA ticket, can anyone tell me:
>
> 1.  Is what I'm doing a covered use case (update a label in a form as
> a result of a AjaxFormComponentUpdatingBehavior event)?
> 2.  Is my approach expected to work?  From the scattered documentation
> I've found, this looks completely feasible.
> 3.  Are there any known issues with the rendering and handling of
> Errors in 1.4-rc2?  This isn't the first time I've encountered some
> really difficult to debug problems, but the fact that this is in an
> AJAX scenario makes this really painful.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org