You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tom Eugelink <tb...@tbee.org> on 2012/04/13 11:58:23 UTC

focus locked in place

I'm slowly getting some ground under my Wicket feet, but now I have a strange problem. I've got a form with two TextFields and a RefreshingView inside a MarkupContainer, building rows containing a DropDownChoice, TextField and a AjaxSubmitLink. The stripped version of the Java code looks like this:

             final Form<MasterLicenseModel> lForm = new Form<MasterLicenseModel>("form", new CompoundPropertyModel(masterLicenseModel)) ;
             add(lForm);

             DatePicker<Date> lValidFromDateTextField = new DatePicker<Date>(LicenseModel.VALIDFROM_PROPERTY)
             lForm.add(lValidFromDateTextField);

             DatePicker lValidUntilDateTextField = new DatePicker(LicenseModel.VALIDUNTIL_PROPERTY);
             lForm.add(lValidUntilDateTextField);

             final MarkupContainer lRuntimesPanel = new WebMarkupContainer("runtimesPanel");
             lRuntimesPanel.setOutputMarkupId(true);
             lForm.add(lRuntimesPanel);

             final RefreshingView<License.Runtime> lRuntimeListView = new RefreshingView<License.Runtime>(LicenseModel.RUNTIMES_PROPERTY)
             {
                 @Override
                 protected void populateItem(final Item<Runtime> item)
                 {
                     item.add( new DropDownChoice<String>("runtimeType", new PropertyModel<String>(item.getDefaultModel(), "type"), License.RUNTIME_TYPES));
                     item.add( new TextField<String>("runtimeOs", new PropertyModel<String>(item.getDefaultModel(), "os")));

                       AjaxSubmitLink lRemoveRuntime = new AjaxSubmitLink("removeRuntime", lForm)
                       lRemoveRuntime.setDefaultFormProcessing(false);
                       item.add(lRemoveRuntime);
                 }
             };
             lRuntimesPanel.add(lRuntimeListView);

             AjaxSubmitLink lAddRuntime = new AjaxSubmitLink("addRuntime", lForm)
             {
             };
             lAddRuntime.setDefaultFormProcessing(false);
             lRuntimesPanel.add(lAddRuntime);

The cursor can be placed in the date fields, but not in any of the textfield in the listview. Focus then immediately jumps to the DropDownChoice in the first row. I've tried removing the MarkupContainer & Ajax part, reverting back to a regular ListView. In the HTML I use a table for the listview, but a bunch of divs instead do not make a difference.

I also see no events on the HTML text element in the listview either.

<input type="text" wicket:id="runtimeOs" style="width:100px;" value="ios" name="runtimesPanel:runtimes:19:runtimeOs">

Any ideas why the focus jumps?

Tom


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


Re: focus locked in place

Posted by Tom Eugelink <tb...@tbee.org>.
This is very sad; I had a label tag (that was copied with the initial HTML) wrapping the whole table.


On 2012-04-19 14:11, Tom Eugelink wrote:
>
> Ok, I've opened wicket's ajax debugger and there is NO ajax call.
>> I hope this helps you find out what causes the jumps in the focused elements.



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


Re: focus locked in place

Posted by Tom Eugelink <tb...@tbee.org>.
Ok, I've opened wicket's ajax debugger and there is NO ajax call. What I see is this:

INFO: focus set on
INFO: focus removed from
INFO: focus set on
INFO: focus removed from

So it seems to me the fields do not have names. However in the HTML I do see a name.
<input type="text" wicket:id="runtimeOs" style="width:100px;" value="ios" name="runtimesPanel:runtimes:1:runtimeOs">

However, there are more of these inputs with the same wicket:id; it's a make shift table build using a RefreshingView
<input type="text" wicket:id="runtimeOs" style="width:100px;" value="bada" name="runtimesPanel:runtimes:2:runtimeOs">
<input type="text" wicket:id="runtimeOs" style="width:100px;" value="bada" name="runtimesPanel:runtimes:3:runtimeOs">
...

I believe I'm doing something wrong in building that make shift table.

             // the panel taking care of the ajax
             final MarkupContainer lRuntimesPanel = new WebMarkupContainer("runtimesPanel");
             lRuntimesPanel.setOutputMarkupId(true);
             lForm.add(lRuntimesPanel);

             // the list of runtimes
             final RefreshingView<com.service2media.licenseframework.service.license.jaxb.Runtime> lRuntimeListView = new RefreshingView<com.service2media.licenseframework.service.license.jaxb.Runtime>("runtimes") //LicenseModel.RUNTIMES_PROPERTY)
             {
                 @Override
                 protected Iterator<IModel<com.service2media.licenseframework.service.license.jaxb.Runtime>> getItemModels()
                 {
                     return new ModelIteratorAdapter(lLicenseJAXB.getRuntimes().getRuntime().iterator())
                     {
                         @Override
                         protected final IModel model(final Object object)
                         {
                             return new CompoundPropertyModel((com.service2media.licenseframework.service.license.jaxb.Runtime) object);
                         }
                     };
                 }

                 @Override
                 protected void populateItem(final Item<com.service2media.licenseframework.service.license.jaxb.Runtime> item)
                 {
                     item.add( new DropDownChoice<String>("runtimeType", new PropertyModel<String>(item.getDefaultModel(), "type"), License.RUNTIME_TYPES));
                     item.add( new TextField<String>("runtimeOs", new PropertyModel<String>(item.getDefaultModel(), "os")));
                     item.add( new TextField<String>("runtimeOsVersion", new PropertyModel<String>(item.getDefaultModel(), "osversion")));
                     item.add( new TextField<String>("runtimePoolId", new PropertyModel<String>(item.getDefaultModel(), "poolid")));
                     item.add( new TextField<BigInteger>("runtimePoolSize", new PropertyModel<BigInteger>(item.getDefaultModel(), "poolsize")));
                       // remove button
                       AjaxSubmitLink lRemoveRuntime = new AjaxSubmitLink("removeRuntime", lForm)
                       {
                           @Override
                           protected void onError(AjaxRequestTarget target, Form<?> form)
                           {
                           }

                           @Override
                           protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                           {
                               List<com.service2media.licenseframework.service.license.jaxb.Runtime> lRuntimes = lLicenseJAXB.getRuntimes().getRuntime();
                               lRuntimes.remove(item.getModelObject());
                               if (target != null) target.add(lRuntimesPanel); // ajax update
                           }

                           @Override
                           protected IAjaxCallDecorator getAjaxCallDecorator()
                           {
                               return new JavascriptConfirmDecorator("Remove the runtime?");
                           }
                       };
                       lRemoveRuntime.setDefaultFormProcessing(false);
                       item.add(lRemoveRuntime);
                 }
             };
             lRuntimesPanel.add(lRuntimeListView);


On 16-4-2012 8:54, Martin Grigorov wrote:
> Hi Tom,
>
> Wicket keeps track of the last focused element only for Ajax requests.
> I.e. Wicket sends a header in the ajax requests with the id of the
> focused element when the Ajax call starter and later when the Ajax
> response is processed it re-focuses this element.
> Additionally there is AjaxRequestTarget#focusComponent(Component)
> method which may be used to focus another element.
>
> If you replace the focused element in the Ajax response then
> lastFocusedId will be obsolete and Wicket wont be able to find the old
> component.
>
> I hope this helps you find out what causes the jumps in the focused elements.
>
> On Fri, Apr 13, 2012 at 5:49 PM, Tom Eugelink<tb...@tbee.org>  wrote:
>> On 2012-04-13 11:58, Tom Eugelink wrote:
>>>
>>>
>>> The cursor can be placed in the date fields, but not in any of the
>>> textfield in the listview.
>>
>>
>> To add some additional information; the cursor can be placed in the
>> textfields by using the TAB key. A mouse click will always jump to the first
>> field. So it seems to be a RefreshingView in combination with a mouse click
>> problem.
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: focus locked in place

Posted by Martin Grigorov <mg...@apache.org>.
Check with Firebug or Dev tools which component is focused before the
Ajax call (see the request headers) and later after the processing of
the Ajax response check whether there is an element with such id in
the DOM tree.

On Mon, Apr 16, 2012 at 10:36 AM, Tom Eugelink <tb...@tbee.org> wrote:
>
> Thanks for the feedback.
>
> So to check if this is the cause, I could simply remove the ajax code.
>
> Tom
>
>
>
>
> On 2012-04-16 08:54, Martin Grigorov wrote:
>>
>> Hi Tom,
>>
>> Wicket keeps track of the last focused element only for Ajax requests.
>> I.e. Wicket sends a header in the ajax requests with the id of the
>> focused element when the Ajax call starter and later when the Ajax
>> response is processed it re-focuses this element.
>> Additionally there is AjaxRequestTarget#focusComponent(Component)
>> method which may be used to focus another element.
>>
>> If you replace the focused element in the Ajax response then
>> lastFocusedId will be obsolete and Wicket wont be able to find the old
>> component.
>>
>> I hope this helps you find out what causes the jumps in the focused
>> elements.
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: focus locked in place

Posted by Tom Eugelink <tb...@tbee.org>.
Thanks for the feedback.

So to check if this is the cause, I could simply remove the ajax code.

Tom



On 2012-04-16 08:54, Martin Grigorov wrote:
> Hi Tom,
>
> Wicket keeps track of the last focused element only for Ajax requests.
> I.e. Wicket sends a header in the ajax requests with the id of the
> focused element when the Ajax call starter and later when the Ajax
> response is processed it re-focuses this element.
> Additionally there is AjaxRequestTarget#focusComponent(Component)
> method which may be used to focus another element.
>
> If you replace the focused element in the Ajax response then
> lastFocusedId will be obsolete and Wicket wont be able to find the old
> component.
>
> I hope this helps you find out what causes the jumps in the focused elements.
>



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


Re: focus locked in place

Posted by Martin Grigorov <mg...@apache.org>.
Hi Tom,

Wicket keeps track of the last focused element only for Ajax requests.
I.e. Wicket sends a header in the ajax requests with the id of the
focused element when the Ajax call starter and later when the Ajax
response is processed it re-focuses this element.
Additionally there is AjaxRequestTarget#focusComponent(Component)
method which may be used to focus another element.

If you replace the focused element in the Ajax response then
lastFocusedId will be obsolete and Wicket wont be able to find the old
component.

I hope this helps you find out what causes the jumps in the focused elements.

On Fri, Apr 13, 2012 at 5:49 PM, Tom Eugelink <tb...@tbee.org> wrote:
>
> On 2012-04-13 11:58, Tom Eugelink wrote:
>>
>>
>>
>> The cursor can be placed in the date fields, but not in any of the
>> textfield in the listview.
>
>
>
> To add some additional information; the cursor can be placed in the
> textfields by using the TAB key. A mouse click will always jump to the first
> field. So it seems to be a RefreshingView in combination with a mouse click
> problem.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: focus locked in place

Posted by Tom Eugelink <tb...@tbee.org>.
On 2012-04-13 11:58, Tom Eugelink wrote:
>
>
> The cursor can be placed in the date fields, but not in any of the textfield in the listview.


To add some additional information; the cursor can be placed in the textfields by using the TAB key. A mouse click will always jump to the first field. So it seems to be a RefreshingView in combination with a mouse click problem.


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