0

Databind and <a> compoment

asked 2010-10-27 08:23:04 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

Hi to all,

I am using Listboxes and Grids along with data binder. My question is rather simple. Is there a way to have a <A> inside a grid row with label populated from the binded model? I mean, how can i achieve something like this:

<row>
     <a href="">@{ person.name }</a>
</row>

Thanks

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2010-10-27 11:25:48 +0800

twiegand gravatar image twiegand
1807 3

Cyiannoulis,

Give this listbox example a whirl. It should give you an idea how to do it.

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk xmlns:h="http://www.w3.org/1999/xhtml">
	<zscript>
		public class Link {
			private String url;
			private String urlDisplay;

			public Link(String u, String ud) {
				setUrl(u);
				setUrlDisplay(ud);
			}

			public String getUrl() {
				return url;
			}
			public void setUrl(String u) {
				url = u;
			}

			public String getUrlDisplay() {
				return urlDisplay;
			}
			public void setUrlDisplay(String ud) {
				urlDisplay = ud;
			}

		}

		List Links = new ArrayList();
		Links.add(new Link("http://www.cnn.com", "www.cnn.com"));
		Links.add(new Link("http://www.apple.com", "www.apple.com"));
		Links.add(new Link("http://www.yahoo.com", "www.yahoo.com"));

	</zscript>
	
	<window id="win" border="normal" style="padding:25px;">
		<listbox id="myListbox" model="@{Links}" selectedItem="@{selected}" >
			<listhead>
				<listheader label="URL Link" />
			</listhead>
			<listitem self="@{each=Link}">
				<listcell> 
					<h:a href="@{Link.url}"><label value="@{Link.urlDisplay}"/></h:a>
				</listcell>
			</listitem>	
		</listbox>
	</window>
</zk>

Regards,

Todd

link publish delete flag offensive edit

answered 2010-10-27 11:37:47 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

Thank you so much Todd. This should work fine!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-10-27 08:23:04 +0800

Seen: 180 times

Last updated: Oct 27 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More