You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2014/03/23 18:26:41 UTC

ajax event not quite working as planned

I have a listview where each row has an expandable section in it to show
additonal detail on some rows.  That works.  But two aspects aren't working.

1) I am trying to change the + on the button to a -, and then back again
when we collapse.  My code looks like:
		if(invokingButton.getLabel().getObject().equals("+"))
			invokingButton.setLabel(new Model<String>("-"));
		else
			invokingButton.setLabel(new Model<String>("+"));
		target.add(invokingButton);

The label never changes.  From stepping in, I can say that yes, the label
set to "-" line does run when expected.  yes, outputmarkupId is set to true.

Button code when created:
	            item.add(new AjaxButton("btnExpander"){
					private static final long serialVersionUID = 1L;
					public void onSubmit(AjaxRequestTarget target, Form form) {
						onActivityLogExpansion(target, this, activity);
					}
	            }.setLabel(new Model<String>("+"))
	             .setOutputMarkupId(true).setVisible(showReject || showSubmit)
	             .setOutputMarkupPlaceholderTag(true));


2) When I go to collapse the row, the event gets to the server, things seem
to work stepping through the code, but then the region does not collapse and
I get the following in the wicket ajax debug:

INFO: 
<?xml version="1.0" encoding="UTF-8"?><ajax-response><component
id="expandableWhenReject4c" ></component><component id="btnExpander47"
></component><header-contribution encoding="wicket1"
></header-contribution><evaluate></evaluate></ajax-response>
ERROR: Wicket.Ajax.Call.processComponent: Component with id
[[expandableWhenReject4c]] was not found while trying to perform markup
update. Make sure you called component.setOutputMarkupId(true) on the
component whose markup you are trying to update.
INFO: Response processed successfully.
INFO: refocus last focused component not needed/allowed
INFO: focus set on wicketDebugLink
INFO: focus removed from wicketDebugLink

The container being hidden is created as:
				WebMarkupContainer expandableReject = new
WebMarkupContainer("expandableWhenReject", new
Model<ShareActivityPlusDecode>((ShareActivityPlusDecode)
item.getDefaultModel().getObject()));
				expandableReject.setVisible(false);
				expandableReject.setOutputMarkupId(true);
				expandableReject.setOutputMarkupPlaceholderTag(true);

and in the event:

			WebMarkupContainer wmc = (WebMarkupContainer)
invokingButton.getParent().get("expandableWhenReject");
			wmc.setVisible(!wmc.isVisible());
			target.add(wmc);

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ajax-event-not-quite-working-as-planned-tp4665083.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ajax event not quite working as planned

Posted by Stefan Renz <s....@efonds.com>.
Hi,

Entropy wrote:
> I solved my button issue by creating two buttons and toggling their
> visibility rather than changing the label on a single button.  i still think
> the original solution should have worked, but I have fixed the problem.

I guess you want to #setBody() instead of #setLabel() -- #setLabel() is
for FormComponent labelling (and AFAIK for feedback messages involving
the form component).

Cheers,
    Stef

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


Re: ajax event not quite working as planned

Posted by Entropy <bl...@gmail.com>.
I solved my button issue by creating two buttons and toggling their
visibility rather than changing the label on a single button.  i still think
the original solution should have worked, but I have fixed the problem.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ajax-event-not-quite-working-as-planned-tp4665083p4665100.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ajax event not quite working as planned

Posted by Entropy <bl...@gmail.com>.
Setting that AND adding the form that contains the list to the target (which
was inspired by that bit of text) seems to have solved issue #2, the
collapse.  Thanks!

However, issue #1, the button label, is still not working correctly.  Any
insight there?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/ajax-event-not-quite-working-as-planned-tp4665083p4665085.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: ajax event not quite working as planned

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

See ListView#setReuseItems() javadoc

Martin Grigorov
Wicket Training and Consulting


On Sun, Mar 23, 2014 at 7:26 PM, Entropy <bl...@gmail.com> wrote:

> I have a listview where each row has an expandable section in it to show
> additonal detail on some rows.  That works.  But two aspects aren't
> working.
>
> 1) I am trying to change the + on the button to a -, and then back again
> when we collapse.  My code looks like:
>                 if(invokingButton.getLabel().getObject().equals("+"))
>                         invokingButton.setLabel(new Model<String>("-"));
>                 else
>                         invokingButton.setLabel(new Model<String>("+"));
>                 target.add(invokingButton);
>
> The label never changes.  From stepping in, I can say that yes, the label
> set to "-" line does run when expected.  yes, outputmarkupId is set to
> true.
>
> Button code when created:
>                     item.add(new AjaxButton("btnExpander"){
>                                         private static final long
> serialVersionUID = 1L;
>                                         public void
> onSubmit(AjaxRequestTarget target, Form form) {
>
> onActivityLogExpansion(target, this, activity);
>                                         }
>                     }.setLabel(new Model<String>("+"))
>                      .setOutputMarkupId(true).setVisible(showReject ||
> showSubmit)
>                      .setOutputMarkupPlaceholderTag(true));
>
>
> 2) When I go to collapse the row, the event gets to the server, things seem
> to work stepping through the code, but then the region does not collapse
> and
> I get the following in the wicket ajax debug:
>
> INFO:
> <?xml version="1.0" encoding="UTF-8"?><ajax-response><component
> id="expandableWhenReject4c" ></component><component id="btnExpander47"
> ></component><header-contribution encoding="wicket1"
> ></header-contribution><evaluate></evaluate></ajax-response>
> ERROR: Wicket.Ajax.Call.processComponent: Component with id
> [[expandableWhenReject4c]] was not found while trying to perform markup
> update. Make sure you called component.setOutputMarkupId(true) on the
> component whose markup you are trying to update.
> INFO: Response processed successfully.
> INFO: refocus last focused component not needed/allowed
> INFO: focus set on wicketDebugLink
> INFO: focus removed from wicketDebugLink
>
> The container being hidden is created as:
>                                 WebMarkupContainer expandableReject = new
> WebMarkupContainer("expandableWhenReject", new
> Model<ShareActivityPlusDecode>((ShareActivityPlusDecode)
> item.getDefaultModel().getObject()));
>                                 expandableReject.setVisible(false);
>                                 expandableReject.setOutputMarkupId(true);
>
> expandableReject.setOutputMarkupPlaceholderTag(true);
>
> and in the event:
>
>                         WebMarkupContainer wmc = (WebMarkupContainer)
> invokingButton.getParent().get("expandableWhenReject");
>                         wmc.setVisible(!wmc.isVisible());
>                         target.add(wmc);
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/ajax-event-not-quite-working-as-planned-tp4665083.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>