in your case however what you want to accomplish is more appropriate via an ajax call decorator imho.
-Igor
On 8/27/06, Eelco Hillenius <
[EMAIL PROTECTED]> wrote:
Here's an interesting case. For an example I'm writing for WIA, I want
to combine an AjaxLink with an attribute modifier. My naive approach
was this:
final AjaxLink removeLink = new AjaxLink(item,
"remove") {
@Override
public void onClick(AjaxRequestTarget target) {
DataBase.getInstance().remove(discount);
discounts = DataBase.getInstance()
.listDiscounts();
DiscountsListView.this.setList(discounts);
DiscountsListView.this.removeAll ();
target.addComponent(tableBody);
}
};
removeLink.add(new AttributeAppender("onclick",
new Model<String>(
"if(!confirm('remove discount for "
+ discount.getCheese().getName()
+ " ?')) return false;"), ";"));
Of course, that doesn't work, as the Ajax link adds a behavior that
simply overrides anything any attribute modifier might have done
/**
* @see wicket.behavior.AbstractAjaxBehavior#onComponentTag(wicket.markup.ComponentTag)
*/
@Override
protected void onComponentTag(final ComponentTag tag)
{
super.onComponentTag(tag);
tag.put(event.getEvent(), getEventHandler());
}
The question now is, what would be an elegant way to let users combine
ajax behaviors and attribute modifiers. I'm not sure what would be
best. If the above code would be:
/**
* @see wicket.behavior.AbstractAjaxBehavior#onComponentTag(wicket.markup.ComponentTag)
*/
@Override
protected void onComponentTag(final ComponentTag tag)
{
tag.put(event.getEvent(), getEventHandler());
super.onComponentTag(tag);
}
I think I would be fine (not tested yet), but I'm not sure if such
implicitness is the best way to go.
WDYT?
Eelco
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Wicket-develop mailing list Wicket-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-develop