You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by zkn <zk...@abv.bg> on 2010/02/03 00:04:10 UTC

Adding AjaxLink to a DataTable cell

Hi,

I'm have a problem adding an AjaxLink to a DataTable cell. Everything works fine except that I don't know how to set the text for the link.
The result is that I see only  "[cell]" as a text in the cell but onClick() works fine.

Here is my code:

columns.add(new AbstractColumn<Book>(new Model<String>("Title")) {

			public void populateItem(Item<ICellPopulator<Book>> cellItem,	String componentId, IModel<Book> model) {

				final Book book = model.getObject();

				if (book.getAuthor() == null) {

				    book.setAuthor( new Author());

				    AjaxLink<String> link = new AjaxLink<String>(componentId, new Model<String>("change author")) {
					@Override
					public void onClick(AjaxRequestTarget target) {
												
					    	modalWindow.setContent(new AuthorSwitchPanel(modalWindow
							.getContentId(), new Model<Author>(book.getAuthor())));
						modalWindow.show(target);
					}
				    };
				    
				    cellItem.add(link);
				}
				else
					cellItem.add(new Label(componentId,
							new PropertyModel<Author>(book.getAuthor(), "name")));
			}
});



Re: Adding AjaxLink to a DataTable cell

Posted by zkn <zk...@abv.bg>.
Thanks.

It worked with 

@Override
			protected void onComponentTagBody(
				MarkupStream markupStream, ComponentTag openTag) {
			    // TODO Auto-generated method stub
			    replaceComponentTagBody(markupStream, openTag,
				    getModelObject());
			}

			@Override
			protected void onComponentTag(ComponentTag tag) {
			    // TODO Auto-generated method stub
			    tag.setName("a");
			    super.onComponentTag(tag);
			}

On 03.02.2010, at 01:06, Igor Vaynberg wrote:

> search this link for TextLink, or create a panel/fragment that contain
> a link and a label
> 
> -igor
> 
> On Tue, Feb 2, 2010 at 3:04 PM, zkn <zk...@abv.bg> wrote:
>> Hi,
>> 
>> I'm have a problem adding an AjaxLink to a DataTable cell. Everything works fine except that I don't know how to set the text for the link.
>> The result is that I see only  "[cell]" as a text in the cell but onClick() works fine.
>> 
>> Here is my code:
>> 
>> columns.add(new AbstractColumn<Book>(new Model<String>("Title")) {
>> 
>>                        public void populateItem(Item<ICellPopulator<Book>> cellItem,   String componentId, IModel<Book> model) {
>> 
>>                                final Book book = model.getObject();
>> 
>>                                if (book.getAuthor() == null) {
>> 
>>                                    book.setAuthor( new Author());
>> 
>>                                    AjaxLink<String> link = new AjaxLink<String>(componentId, new Model<String>("change author")) {
>>                                        @Override
>>                                        public void onClick(AjaxRequestTarget target) {
>> 
>>                                                modalWindow.setContent(new AuthorSwitchPanel(modalWindow
>>                                                        .getContentId(), new Model<Author>(book.getAuthor())));
>>                                                modalWindow.show(target);
>>                                        }
>>                                    };
>> 
>>                                    cellItem.add(link);
>>                                }
>>                                else
>>                                        cellItem.add(new Label(componentId,
>>                                                        new PropertyModel<Author>(book.getAuthor(), "name")));
>>                        }
>> });
>> 
>> 
>> 


Re: Adding AjaxLink to a DataTable cell

Posted by Igor Vaynberg <ig...@gmail.com>.
s/search this link/search this list/

-igor

On Tue, Feb 2, 2010 at 3:06 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> search this link for TextLink, or create a panel/fragment that contain
> a link and a label
>
> -igor
>
> On Tue, Feb 2, 2010 at 3:04 PM, zkn <zk...@abv.bg> wrote:
>> Hi,
>>
>> I'm have a problem adding an AjaxLink to a DataTable cell. Everything works fine except that I don't know how to set the text for the link.
>> The result is that I see only  "[cell]" as a text in the cell but onClick() works fine.
>>
>> Here is my code:
>>
>> columns.add(new AbstractColumn<Book>(new Model<String>("Title")) {
>>
>>                        public void populateItem(Item<ICellPopulator<Book>> cellItem,   String componentId, IModel<Book> model) {
>>
>>                                final Book book = model.getObject();
>>
>>                                if (book.getAuthor() == null) {
>>
>>                                    book.setAuthor( new Author());
>>
>>                                    AjaxLink<String> link = new AjaxLink<String>(componentId, new Model<String>("change author")) {
>>                                        @Override
>>                                        public void onClick(AjaxRequestTarget target) {
>>
>>                                                modalWindow.setContent(new AuthorSwitchPanel(modalWindow
>>                                                        .getContentId(), new Model<Author>(book.getAuthor())));
>>                                                modalWindow.show(target);
>>                                        }
>>                                    };
>>
>>                                    cellItem.add(link);
>>                                }
>>                                else
>>                                        cellItem.add(new Label(componentId,
>>                                                        new PropertyModel<Author>(book.getAuthor(), "name")));
>>                        }
>> });
>>
>>
>>
>

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


Re: Adding AjaxLink to a DataTable cell

Posted by Igor Vaynberg <ig...@gmail.com>.
search this link for TextLink, or create a panel/fragment that contain
a link and a label

-igor

On Tue, Feb 2, 2010 at 3:04 PM, zkn <zk...@abv.bg> wrote:
> Hi,
>
> I'm have a problem adding an AjaxLink to a DataTable cell. Everything works fine except that I don't know how to set the text for the link.
> The result is that I see only  "[cell]" as a text in the cell but onClick() works fine.
>
> Here is my code:
>
> columns.add(new AbstractColumn<Book>(new Model<String>("Title")) {
>
>                        public void populateItem(Item<ICellPopulator<Book>> cellItem,   String componentId, IModel<Book> model) {
>
>                                final Book book = model.getObject();
>
>                                if (book.getAuthor() == null) {
>
>                                    book.setAuthor( new Author());
>
>                                    AjaxLink<String> link = new AjaxLink<String>(componentId, new Model<String>("change author")) {
>                                        @Override
>                                        public void onClick(AjaxRequestTarget target) {
>
>                                                modalWindow.setContent(new AuthorSwitchPanel(modalWindow
>                                                        .getContentId(), new Model<Author>(book.getAuthor())));
>                                                modalWindow.show(target);
>                                        }
>                                    };
>
>                                    cellItem.add(link);
>                                }
>                                else
>                                        cellItem.add(new Label(componentId,
>                                                        new PropertyModel<Author>(book.getAuthor(), "name")));
>                        }
> });
>
>
>