Label does not have an onClick() method, so nobody will be calling your
onClick() ;)
If you want to attach AJAX behavior to the label you should do the following:
final Label label = new Label("label", item.getModel());
label.add(new AjaxEventBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
// do something
}
});
item.add(label);
On 14.06.2012 at 17:27 oliver.stef wrote:
> Hi,
>
> i want to use a label inside listView and i want the user will press on the
> label - and the
> onClick method will work. but what i get is this msg.:
>
> "The method onClick() from the type new Label(){} is never used locally".
> I don't know why?!?!?!?!?!
>
> this is my implement:
>
> List list = Arrays.asList(new String[] { "a", "b", "c" });
>
> @SuppressWarnings("unchecked")
> ListView listview = new ListView("listview", list) {
>
>
> protected void populateItem(ListItem item) {
>
> String s = (String)item.getModelObject();
> item.add(new Label("label", item.getModel())
> {
> private static final long
> serialVersionUID = 1L;
>
> private void onClick()
> {
> System.out.println("Hello);
>
> }
> }
> );
> }
> };
> add(listview);
>
> thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]