Hi wicketers,
I have fixed this issue by including form in target component:

        private void registerBehaviors() {
            userAgentField.add(new OnChangeAjaxBehavior() {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {

                    logger.debug("AJAX matching user agent");

                    matchUserAgent();
                    target.addComponent(resultPanel);
                    target.addComponent(matchingForm);
                }
            });
        }

I've found this mail:
http://www.nabble.com/OnChangeAjaxBehavior-receives-only-first-input-character-td20207317.html,
it is the same issue.

It is this behavior default? or it is an issue?

2009/3/18 Filippo De Luca <[email protected]>

> Hi,
> I have a panel MatchingPanel with a form and a result div:
>
>         <wicket:panel>
>
>             <form wicket:id="form" action="#">
>                 <div class="widget">
>                     <label><wicket:message
> key="form.userAgent">[form.userAgent]</wicket:message></label>
>                     <input wicket:id="userAgent" class="userAgent"
> type="text" maxlength="255" />
>                 </div>
>                 <div class="buttons">
>                     <input type="submit" value="Match"
> wicket:message="value:form.match" />
>                 </div>
>             </form>
>             <div wicket:id="result" >
>                 <div>
>                     <label><wicket:message
> key="result.matchedUserAgent">[result.matchedUserAgent]</wicket:message></label>
>                     <span
> wicket:id="matchedUserAgent">[sourceUserAgent]</span>
>                 </div>
>             </div>
>         </wicket:panel>
>
> while my java code is:
>
>     class MatchingForm extends Form<Object> {
>
> ...
>
>         private void registerBehaviors() {
>             userAgentField.add(new OnChangeAjaxBehavior() {
>
>                 @Override
>                 protected void onUpdate(AjaxRequestTarget target) {
>
>                     logger.debug("AJAX matching user agent");
>
>                     matchUserAgent();
>                     target.addComponent(resultPanel);
>                 }
>             });
>         }
>
> ...
>
>         private void matchUserAgent() {
>
>             String userAgent = userAgentModel.getObject();
>             WURFLManager wurflManager = getWurflManager();
>
>             MatchingResult result = null;
>
>             if (StringUtils.isNotBlank(userAgent)) {
>
>                 Instant start = new Instant();
>                 Device device =
> wurflManager.getDeviceForRequest(userAgent);
>                 Instant end = new Instant();
>
>                 Period duration = new Period(start, end);
>                 result = new MatchingResult(userAgent, device, (long)
> duration
>                         .getMillis());
>
>             }
>             resultPanel.setResult(result);
>
>         }
>
>     }
>
> The OnChangeBehaviour is called only the first time the userAgent field
> take the focus. To call other time, i have to lost focus and give focus to
> userAgent input text. Why? The target component is outside the frm, it is an
> issue?
>
> Thank you
>
> --
> Filippo De Luca
> --------------------------
> Email: [email protected]
> Web:   http://www.filosganga.it
> LinkedIn: http://www.linkedin.com/in/filippodeluca
> mobile: +393395822588
>



-- 
Filippo De Luca
--------------------------
Email: [email protected]
Web:   http://www.filosganga.it
LinkedIn: http://www.linkedin.com/in/filippodeluca
mobile: +393395822588

Reply via email to