You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by trlt <tr...@gmail.com> on 2018/05/27 02:47:47 UTC

StatelessAjaxFallbackLink questions

I have a very simple program: list of links which prints a message when the
selected link is clicked. It works fine when I use AjaxLink or
StatelessLink, but I am having issues when I changed it to
StatelessAjaxFallbackLink (from wicketstuff-stateless package).  Instead of
printing that's selected, it prints the list of all the links when the FIRST
link is selected.  It works as expected for other links:

ListView links = new ListView("links", LIST) {

			@Override
			protected void populateItem(final ListItem item) {
				final Label linkLabel = new Label("linkLabel", new
Model(item.getDefaultModelObjectAsString()));

			
				StatelessAjaxFallbackLink link = new StatelessAjaxFallbackLink("link") {

					@Override
					public void onClick(AjaxRequestTarget target) {
						System.out.println("selected: " +
linkLabel.getDefaultModelObjectAsString());
					}
				};
				item.add(link.add(linkLabel));
			}
		};
		add(links);



myproject.gz
<http://apache-wicket.1842946.n4.nabble.com/file/t374889/myproject.gz>  

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: StatelessAjaxFallbackLink questions

Posted by trlt <tr...@gmail.com>.
Thanks Sven!

Your fix works, but had I used wicket 7 sooner, I would not have encountered
the problem I was having.

Thanks again!



Sven Meier wrote
> Hi,
> 
> wicketstuff's StatelessAjaxFallbackLink sets its own id as its markupId. 
> I'm not sure why it is doing that (perhaps to prevent a session?),
> but now all your links use the identical markupId "link", and all Ajax 
> behaviors bind to the first anchor tag:
> 
> - clicking on the first link triggers all three ajax events simultaneously
> 
> - while clicking on the second or third link triggers the fallback for 
> the corresponding link
> 
> Note that wicketstuff-stateless has been deprecated in 7.x and removed 
> in 8.x, since Wicket now already comes with similar classes.
> 
> As a workaround you can alter the markup id by yourself:
> 
>                  StatelessAjaxFallbackLink link = new 
> StatelessAjaxFallbackLink("link") {
>                      @Override
>                      protected void onInitialize() {
>                          super.onInitialize();
> 
>                          setMarkupId(getPageRelativePath());
>                      }
> 
> I'd recommend switching to Wicket 7.x or 8.x, as 6.x will no longer get 
> updates.
> 
> Have fun
> Sven
> 
> 
> Am 27.05.2018 um 04:47 schrieb trlt:
>> I have a very simple program: list of links which prints a message when
>> the
>> selected link is clicked. It works fine when I use AjaxLink or
>> StatelessLink, but I am having issues when I changed it to
>> StatelessAjaxFallbackLink (from wicketstuff-stateless package).  Instead
>> of
>> printing that's selected, it prints the list of all the links when the
>> FIRST
>> link is selected.  It works as expected for other links:
>>
>> ListView links = new ListView("links", LIST) {
>>
>> 			@Override
>> 			protected void populateItem(final ListItem item) {
>> 				final Label linkLabel = new Label("linkLabel", new
>> Model(item.getDefaultModelObjectAsString()));
>>
>> 			
>> 				StatelessAjaxFallbackLink link = new
>> StatelessAjaxFallbackLink("link") {
>>
>> 					@Override
>> 					public void onClick(AjaxRequestTarget target) {
>> 						System.out.println("selected: " +
>> linkLabel.getDefaultModelObjectAsString());
>> 					}
>> 				};
>> 				item.add(link.add(linkLabel));
>> 			}
>> 		};
>> 		add(links);
>>
>>
>>
>> myproject.gz
>> &lt;http://apache-wicket.1842946.n4.nabble.com/file/t374889/myproject.gz&gt;
>>
>> --
>> Sent from:
>> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: 

> users-unsubscribe@.apache

>> For additional commands, e-mail: 

> users-help@.apache

>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 

> users-unsubscribe@.apache

> For additional commands, e-mail: 

> users-help@.apache



--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

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


Re: StatelessAjaxFallbackLink questions

Posted by Sven Meier <sv...@meiers.net>.
Hi,

wicketstuff's StatelessAjaxFallbackLink sets its own id as its markupId. 
I'm not sure why it is doing that (perhaps to prevent a session?),
but now all your links use the identical markupId "link", and all Ajax 
behaviors bind to the first anchor tag:

- clicking on the first link triggers all three ajax events simultaneously

- while clicking on the second or third link triggers the fallback for 
the corresponding link

Note that wicketstuff-stateless has been deprecated in 7.x and removed 
in 8.x, since Wicket now already comes with similar classes.

As a workaround you can alter the markup id by yourself:

                 StatelessAjaxFallbackLink link = new 
StatelessAjaxFallbackLink("link") {
                     @Override
                     protected void onInitialize() {
                         super.onInitialize();

                         setMarkupId(getPageRelativePath());
                     }

I'd recommend switching to Wicket 7.x or 8.x, as 6.x will no longer get 
updates.

Have fun
Sven


Am 27.05.2018 um 04:47 schrieb trlt:
> I have a very simple program: list of links which prints a message when the
> selected link is clicked. It works fine when I use AjaxLink or
> StatelessLink, but I am having issues when I changed it to
> StatelessAjaxFallbackLink (from wicketstuff-stateless package).  Instead of
> printing that's selected, it prints the list of all the links when the FIRST
> link is selected.  It works as expected for other links:
>
> ListView links = new ListView("links", LIST) {
>
> 			@Override
> 			protected void populateItem(final ListItem item) {
> 				final Label linkLabel = new Label("linkLabel", new
> Model(item.getDefaultModelObjectAsString()));
>
> 			
> 				StatelessAjaxFallbackLink link = new StatelessAjaxFallbackLink("link") {
>
> 					@Override
> 					public void onClick(AjaxRequestTarget target) {
> 						System.out.println("selected: " +
> linkLabel.getDefaultModelObjectAsString());
> 					}
> 				};
> 				item.add(link.add(linkLabel));
> 			}
> 		};
> 		add(links);
>
>
>
> myproject.gz
> <http://apache-wicket.1842946.n4.nabble.com/file/t374889/myproject.gz>
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> 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