You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by shetc <sh...@bellsouth.net> on 2011/02/01 17:40:57 UTC

Using DataView newItem method to display a BreadCrumbPanel

Hi All,

I am trying to add an onclick event to a table row -- each row is created
using a DataView.
To make an entire row clickable, I add an AjaxEventBehavior via the
DataView's Item newItem method.
This seems to work as far as an onEvent event being raised when I click on a
table row.
However, I am trying to activate a BreadCrumbPanel from within the onEvent
event. Nothing seems
to happen as far as showing the next panel (called JobDescPanel). If I click
on the row again
then a component not found on page exception is thrown. I have supplied a
snippet of code below.
Is it wrong to try and activate a breadcrumb from this Ajax event?

Thanks,
Steve

P.S. Using Wicket 1.4.10


	private void buildDataView() 
	{
		final DataView<JobSearchResult> dv = new
DataView<JobSearchResult>("dataView", jsdp) {
			private static final long serialVersionUID = 1L;

			@Override
			protected Item<JobSearchResult> newItem(String id, int index, final
IModel<JobSearchResult> model) {
				Item<JobSearchResult> item = super.newItem(id, index, model);
				item.add(new AjaxEventBehavior("onclick") {
					private static final long serialVersionUID = 1L;
					@Override
					protected void onEvent(AjaxRequestTarget target) {
						activate(new IBreadCrumbPanelFactory() {
							private static final long serialVersionUID = 1L;
							public BreadCrumbPanel create(String componentId, IBreadCrumbModel
bcm) {
								JobSearchResult jsr = model.getObject();
								return new JobDescPanel(componentId, bcm, homePage,
jsr.getOrderId());
							}
						});
					}
				});
				return item;
			}

			...
	}

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DataView-newItem-method-to-display-a-BreadCrumbPanel-tp3252215p3252215.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: Using DataView newItem method to display a BreadCrumbPanel

Posted by msj121 <ms...@gmail.com>.
Well if you have the Panel

Panel pnl = new Panel("breadcumbholder");
pnl.setOutputMarkupId(true);

and if this panel is made global, then you can add it inside other classes
if necessary.... target.addComponent(pnl);

This way you only update the panel and not the entire page....



shetc wrote:
> 
> I seemed to have resolved the issue by adding the page that owns the bread
> crumb panels as the
> Ajax target; I do this within the BreadCrumbPanel create method:
> 
> 
> getPage().setOutputMarkupId(true);
> target.addComponent(getPage());
> 
> 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DataView-newItem-method-to-display-a-BreadCrumbPanel-tp3252215p3259442.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: Using DataView newItem method to display a BreadCrumbPanel

Posted by shetc <sh...@bellsouth.net>.
I seemed to have resolved the issue by adding the page that owns the bread
crumb panels as the
Ajax target; I do this within the BreadCrumbPanel create method:


getPage().setOutputMarkupId(true);
target.addComponent(getPage());

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DataView-newItem-method-to-display-a-BreadCrumbPanel-tp3252215p3259004.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: Using DataView newItem method to display a BreadCrumbPanel

Posted by shetc <sh...@bellsouth.net>.
Thanks for the reply Matthew. Unfortunately, I'm not sure how to pass the
panel to the target.
Putting it within the IBreadCrumbPanelFactory create method seems to have no
effect.


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DataView-newItem-method-to-display-a-BreadCrumbPanel-tp3252215p3258184.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: Using DataView newItem method to display a BreadCrumbPanel

Posted by msj121 <ms...@gmail.com>.
not sure what activate does, I would hope though that it would add the object
to a panel on the page, and then you call "target.addComponent(<panel>);" As
this target (the AjaxRequestTarget) deals with actually updating the front
end of the page.

Also Data Repeaters are somewhat dubious in that they refresh their content
on each reload, so don't try to add the content to the DataView itself
(which I assume you are not). Similarly using the model and not the value of
the model might cause some issues, I am not sure. The stack error trace
after this first visual issue is fixed would be useful.

I do presume they are somewhat separate (ie: fixing one won't solve the
other).

Matthew


shetc wrote:
> 
> Hi All,
> 
> I am trying to add an onclick event to a table row -- each row is created
> using a DataView.
> To make an entire row clickable, I add an AjaxEventBehavior via the
> DataView's Item newItem method.
> This seems to work as far as an onEvent event being raised when I click on
> a table row.
> However, I am trying to activate a BreadCrumbPanel from within the onEvent
> event. Nothing seems
> to happen as far as showing the next panel (called JobDescPanel). If I
> click on the row again
> then a component not found on page exception is thrown. I have supplied a
> snippet of code below.
> Is it wrong to try and activate a breadcrumb from this Ajax event?
> 
> Thanks,
> Steve
> 
> P.S. Using Wicket 1.4.10
> 
> 
> 	private void buildDataView() 
> 	{
> 		final DataView<JobSearchResult> dv = new
> DataView<JobSearchResult>("dataView", jsdp) {
> 			private static final long serialVersionUID = 1L;
> 
> 			@Override
> 			protected Item<JobSearchResult> newItem(String id, int index, final
> IModel<JobSearchResult> model) {
> 				Item<JobSearchResult> item = super.newItem(id, index, model);
> 				item.add(new AjaxEventBehavior("onclick") {
> 					private static final long serialVersionUID = 1L;
> 					@Override
> 					protected void onEvent(AjaxRequestTarget target) {
> 						activate(new IBreadCrumbPanelFactory() {
> 							private static final long serialVersionUID = 1L;
> 							public BreadCrumbPanel create(String componentId, IBreadCrumbModel
> bcm) {
> 								JobSearchResult jsr = model.getObject();
> 								return new JobDescPanel(componentId, bcm, homePage,
> jsr.getOrderId());
> 							}
> 						});
> 					}
> 				});
> 				return item;
> 			}
> 
> 			...
> 	}
> 
> 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DataView-newItem-method-to-display-a-BreadCrumbPanel-tp3252215p3252973.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