You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Joshua Martin <jo...@gmail.com> on 2009/06/25 18:32:49 UTC
AjaxFallbackLink Text
Trying to add an AjaxFallbackLink to a DataTable via an AbstractColumn
and I can't figure out how to set the text in the cell to say
something like "view details" or something.
I know that in the constructor, the String is for the component's ID,
and I thought that the model was for the text in the link - apparently
not...
// Abstract column for showing a pop up window with details
columns.add(new AbstractColumn(new Model("Actions")) {
public void populateItem(Item cellItem, String
componentId, IModel rowModel) {
final Workstation item = (Workstation)rowModel.getObject();
// HashMap for all the item's values - will be sent to window
final HashMap<String, String> map = new
HashMap<String, String>();
map.put("AGENTIDENTIFIER", item.getAgentIdentifier());
map.put("HOSTNAME", item.getHostname());
map.put("DOMAIN", item.getDomainname());
map.put("FQDN", item.getFqdn());
map.put("IP","The IP Address");
map.put("NETMASK", "The Netmask");
map.put("GATEWAY", item.getGateway());
map.put("DNS1", item.getDns1());
map.put("DNS2", item.getDns2());
// ModalWindow functions as a pop up window with the
item's details
final ModalWindow modalWindowDetail;
add(modalWindowDetail = new ModalWindow("modalWindowDetail"));
// Action for close button callback
modalWindowDetail.setCloseButtonCallback(new
ModalWindow.CloseButtonCallback()
{
public boolean
onCloseButtonClicked(AjaxRequestTarget target)
{
return true;
}
});
// Action for window close
modalWindowDetail.setWindowClosedCallback(new
ModalWindow.WindowClosedCallback()
{
public void onClose(AjaxRequestTarget target)
{
// Do Nothing
}
});
AjaxFallbackLink link = new
AjaxFallbackLink(componentId, new Model("asdfasdf")) {
@Override
public void onClick(AjaxRequestTarget target) {
System.out.println("Viewed Details for " +
item.getAgentIdentifier());
modalWindowDetail.setTitle("Detail: " +
item.getHostname());
modalWindowDetail.setCookieName("modal-window-detail");
modalWindowDetail.setContent(new
ModalPanel1(modalWindowDetail.getContentId(), map));
modalWindowDetail.show(target);
}
};
cellItem.add(link);
}
});
--
_________________________________
Joshua S. Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AjaxFallbackLink Text
Posted by Joshua Martin <jo...@gmail.com>.
Finally figured it out... For the benefit of others, my entire page
with the AjaxFallbackLink w/ custom text:
@SuppressWarnings("serial")
public AssetsPage () {
// List for columns
List<IColumn> columns = new ArrayList<IColumn>();
// Abstract column for showing a pop up window with details
columns.add(new AbstractColumn(new Model("")) {
public void populateItem(Item cellItem, String componentId,
IModel rowModel) {
final Workstation item = (Workstation)rowModel.getObject();
// HashMap for all the item's values - will be sent to window
final HashMap<String, String> map = new HashMap<String, String>();
map.put("AGENTIDENTIFIER", item.getAgentIdentifier());
map.put("HOSTNAME", item.getHostname());
map.put("DOMAIN", item.getDomainname());
map.put("FQDN", item.getFqdn());
map.put("IP","The IP Address");
map.put("NETMASK", "The Netmask");
map.put("GATEWAY", item.getGateway());
map.put("DNS1", item.getDns1());
map.put("DNS2", item.getDns2());
// ModalWindow functions as a pop up window with the item's details
final ModalWindow modalWindowDetail;
add(modalWindowDetail = new ModalWindow("modalWindowDetail"));
// Action for close button callback
modalWindowDetail.setCloseButtonCallback(new
ModalWindow.CloseButtonCallback()
{
public boolean onCloseButtonClicked(AjaxRequestTarget target)
{
return true;
}
});
// Action for window close
modalWindowDetail.setWindowClosedCallback(new
ModalWindow.WindowClosedCallback()
{
public void onClose(AjaxRequestTarget target)
{
// Do Nothing
}
});
AjaxFallbackLink link = new AjaxFallbackLink(componentId) {
@Override
public void onClick(AjaxRequestTarget target) {
System.out.println("Viewed Details for " + item.getAgentIdentifier());
modalWindowDetail.setTitle("Detail: " + item.getHostname());
modalWindowDetail.setCookieName("modal-window-detail");
modalWindowDetail.setContent(new
ModalPanel1(modalWindowDetail.getContentId(), map));
modalWindowDetail.show(target);
}
public void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
String linkText = "<a href=\"#\">View Details</a>";
replaceComponentTagBody(markupStream, openTag, linkText);
}
};
cellItem.add(link);
}
});
// Property columns
columns.add(new PropertyColumn(new Model("Agent Identifier"),
"agentIdentifier", "agentIdentifier"));
columns.add(new PropertyColumn(new Model("Hostname"), "hostname",
"hostname"));
columns.add(new PropertyColumn(new Model("FQDN"), "fqdn", "fqdn"));
// Add the datatable to the page
add(new DefaultDataTable("datatable", columns, new
SortableWorkstationProvider(), 8));
}
--
_________________________________
Joshua S. Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AjaxFallbackLink Text
Posted by Martin Grigorov <mc...@e-card.bg>.
or override onComponentTagBody() and use the model instead of a Label.
El dom, 28-06-2009 a las 11:09 +0200, Martijn Dashorst escribió:
> It is for an object you can use in the onclick handler.
>
> new AjaxFallbackLink<Person>("oo", new Model(person)) {
> onclick() {
> Person p = getModelObject();
> p.delete();
> }
> }
>
> to display dynamic text inside the link, just nest a Label component
> inside the link.
>
> <a href="#" wicket:id="link"><span wicket:id="label"></span></a>
>
> Link link = new Link(.....){};
> Label label = new Label(....);
> link.add(label);
> add(link)
>
> Martijn
>
> On Sun, Jun 28, 2009 at 8:54 AM, <Be...@actrix.co.nz> wrote:
> > Hi,
> >
> > I cannot find the purpose of the IModel constructor argument in
> > AjaxFallbackLink(java.lang.String id, IModel<T> model) as I was also
> > trying to modify the anchor text via the IModel with AJAX.
> >
> > What is it?
> >
> > Many thanks.
> >
> > Bernard
> >
> >
> > On Thu, 25 Jun 2009 12:11:37 -0500, you wrote:
> >
> >>Two ways come to mind:
> >>- override onComponentTagBody and write it directly to the response
> >>- use a wicket:fragment - add the fragment to the column, the link to
> >>the fragment, and define the text in the html (or use wicket:message,
> >>etc)
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AjaxFallbackLink Text
Posted by Martijn Dashorst <ma...@gmail.com>.
It is for an object you can use in the onclick handler.
new AjaxFallbackLink<Person>("oo", new Model(person)) {
onclick() {
Person p = getModelObject();
p.delete();
}
}
to display dynamic text inside the link, just nest a Label component
inside the link.
<a href="#" wicket:id="link"><span wicket:id="label"></span></a>
Link link = new Link(.....){};
Label label = new Label(....);
link.add(label);
add(link)
Martijn
On Sun, Jun 28, 2009 at 8:54 AM, <Be...@actrix.co.nz> wrote:
> Hi,
>
> I cannot find the purpose of the IModel constructor argument in
> AjaxFallbackLink(java.lang.String id, IModel<T> model) as I was also
> trying to modify the anchor text via the IModel with AJAX.
>
> What is it?
>
> Many thanks.
>
> Bernard
>
>
> On Thu, 25 Jun 2009 12:11:37 -0500, you wrote:
>
>>Two ways come to mind:
>>- override onComponentTagBody and write it directly to the response
>>- use a wicket:fragment - add the fragment to the column, the link to
>>the fragment, and define the text in the html (or use wicket:message,
>>etc)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AjaxFallbackLink Text
Posted by Be...@actrix.co.nz.
Hi,
I cannot find the purpose of the IModel constructor argument in
AjaxFallbackLink(java.lang.String id, IModel<T> model) as I was also
trying to modify the anchor text via the IModel with AJAX.
What is it?
Many thanks.
Bernard
On Thu, 25 Jun 2009 12:11:37 -0500, you wrote:
>Two ways come to mind:
>- override onComponentTagBody and write it directly to the response
>- use a wicket:fragment - add the fragment to the column, the link to
>the fragment, and define the text in the html (or use wicket:message,
>etc)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: AjaxFallbackLink Text
Posted by Jeremy Thomerson <je...@wickettraining.com>.
Two ways come to mind:
- override onComponentTagBody and write it directly to the response
- use a wicket:fragment - add the fragment to the column, the link to
the fragment, and define the text in the html (or use wicket:message,
etc)
--
Jeremy Thomerson
http://www.wickettraining.com
On Thu, Jun 25, 2009 at 11:32 AM, Joshua Martin<jo...@gmail.com> wrote:
> Trying to add an AjaxFallbackLink to a DataTable via an AbstractColumn
> and I can't figure out how to set the text in the cell to say
> something like "view details" or something.
>
> I know that in the constructor, the String is for the component's ID,
> and I thought that the model was for the text in the link - apparently
> not...
>
>
> // Abstract column for showing a pop up window with details
> columns.add(new AbstractColumn(new Model("Actions")) {
>
> public void populateItem(Item cellItem, String
> componentId, IModel rowModel) {
>
> final Workstation item = (Workstation)rowModel.getObject();
>
> // HashMap for all the item's values - will be sent to window
> final HashMap<String, String> map = new
> HashMap<String, String>();
> map.put("AGENTIDENTIFIER", item.getAgentIdentifier());
> map.put("HOSTNAME", item.getHostname());
> map.put("DOMAIN", item.getDomainname());
> map.put("FQDN", item.getFqdn());
> map.put("IP","The IP Address");
> map.put("NETMASK", "The Netmask");
> map.put("GATEWAY", item.getGateway());
> map.put("DNS1", item.getDns1());
> map.put("DNS2", item.getDns2());
>
> // ModalWindow functions as a pop up window with the
> item's details
> final ModalWindow modalWindowDetail;
> add(modalWindowDetail = new ModalWindow("modalWindowDetail"));
>
> // Action for close button callback
> modalWindowDetail.setCloseButtonCallback(new
> ModalWindow.CloseButtonCallback()
> {
> public boolean
> onCloseButtonClicked(AjaxRequestTarget target)
> {
> return true;
> }
> });
>
> // Action for window close
> modalWindowDetail.setWindowClosedCallback(new
> ModalWindow.WindowClosedCallback()
> {
> public void onClose(AjaxRequestTarget target)
> {
> // Do Nothing
> }
> });
>
>
> AjaxFallbackLink link = new
> AjaxFallbackLink(componentId, new Model("asdfasdf")) {
>
> @Override
> public void onClick(AjaxRequestTarget target) {
> System.out.println("Viewed Details for " +
> item.getAgentIdentifier());
> modalWindowDetail.setTitle("Detail: " +
> item.getHostname());
> modalWindowDetail.setCookieName("modal-window-detail");
> modalWindowDetail.setContent(new
> ModalPanel1(modalWindowDetail.getContentId(), map));
> modalWindowDetail.show(target);
> }
> };
>
> cellItem.add(link);
> }
>
> });
>
> --
> _________________________________
>
> Joshua S. Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org