You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by lang <de...@telfort.nl> on 2012/06/03 14:15:34 UTC

Need a link in a dataview filter column

Hi, in my datatable i use different columns with filters. One of those
columns contain a invoice number
I want to show a pdf if a user click this row

Example
Order      invoice 
<input> <input>
1001      123401    <--- This column must be clicable. After click it must
open a pdf with 123401.pdf
Who can help?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-a-link-in-a-dataview-filter-column-tp4649688.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Need a link in a dataview filter column

Posted by Adam Gray <ad...@gmail.com>.
The first thing I see, though probably unrelated to not getting the label
to show up is:

> PdfLinkPanel panel = new PdfLinkPanel(componentId, new
> Model(""+rowModel));

Just do PdfLinkPanel panel = new PdfLinkPanel(componentId, rowModel);
The row model is already a Model, and appending an empty string to it
doesn't do what it looks like it might be doing.  But, you aren't using
that passed in model anyway, so the point there is somewhat moot, unless
it's resolving the model by traversing up the component hierarchy.  In the
PdfLinkPanel, the call to super should probably be super(id, model);

I'm not sure if the email stripped out your html, but I don't see an anchor
tag or a tag for the label in the PdfLinkPanel markup.  It should be
something like:

<a wicket:id="downloadLink"><span wicket:id="outputText">Label Shows Up
Here</span></a>

I'm just seeing:

# <wicket:id="outputText"/>

On Sun, Jun 3, 2012 at 9:24 AM, lang <de...@telfort.nl> wrote:

> Hi, first; i need the download option for each row in the table, Not in the
> filter.
> In my Java program i did:
>
>        @SuppressWarnings({ "unchecked", "rawtypes", "serial" })
>        public TextFilteredPropertyColumn getLink(String header,String
> sort,String
> field) {
>                return new TextFilteredPropertyColumn<String,IModel>(new
> Model<String>(header), sort, field) {
>                        @Override public void populateItem(final
> Item<ICellPopulator&lt;String>>
> item, final String componentId, final IModel<String> rowModel){
>                                PdfLinkPanel panel = new
> PdfLinkPanel(componentId, new
> Model(""+rowModel));
>                                item.add(panel);
>                                }
>                        @Override
>                        public String getCssClass() {
>                                return "text";
>                        };
>                };
>        }
>
> And in PdfLinkPanel
>   <html xmlns:wicket>
>   <wicket:panel>
>    # <wicket:id=&quot;outputText&quot;/>
>   </wicket:panel>
>   </html>
> public class PdfLinkPanel extends Panel {
>        public PdfLinkPanel(String id, IModel<String> model) {
>                super(id);
>                super(id);
>                DownloadLink downloadLink = new
> DownloadLink("downloadLink",new
> File("mann_oe.pdf"));
>                Label label = new Label("outputText","Factuur");
>
>                add( downloadLink );
>                downloadLink.add(label);
>
> But instead of a link in my column table i only see this    [cell]
> It does work but does not show the invoice number as a link (just only the
> constant [cell] )
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Need-a-link-in-a-dataview-filter-column-tp4649688p4649691.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Need a link in a dataview filter column

Posted by lang <de...@telfort.nl>.
Hi, first; i need the download option for each row in the table, Not in the
filter.
In my Java program i did:

	@SuppressWarnings({ "unchecked", "rawtypes", "serial" })
	public TextFilteredPropertyColumn getLink(String header,String sort,String
field) {
		return new TextFilteredPropertyColumn<String,IModel>(new
Model<String>(header), sort, field) {
			@Override public void populateItem(final Item<ICellPopulator&lt;String>>
item, final String componentId, final IModel<String> rowModel){   
				PdfLinkPanel panel = new PdfLinkPanel(componentId, new
Model(""+rowModel));
				item.add(panel);
				}
			@Override
			public String getCssClass() {  
				return "text"; 
			};		
		};	  
	}

And in PdfLinkPanel
   <html xmlns:wicket>
   <wicket:panel>
    # <wicket:id=&quot;outputText&quot;/> 
   </wicket:panel>
   </html>
public class PdfLinkPanel extends Panel {
	public PdfLinkPanel(String id, IModel<String> model) {
		super(id);
		super(id);
		DownloadLink downloadLink = new DownloadLink("downloadLink",new
File("mann_oe.pdf"));
		Label label = new Label("outputText","Factuur");
		
		add( downloadLink );
		downloadLink.add(label);

But instead of a link in my column table i only see this    [cell]
It does work but does not show the invoice number as a link (just only the
constant [cell] )


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Need-a-link-in-a-dataview-filter-column-tp4649688p4649691.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Need a link in a dataview filter column

Posted by Adam Gray <ad...@gmail.com>.
Did you want to put the link in the rows of the datatable or in the header
row with the filter column itself?

If you're just adding the links to the data rows, I typically use a
Fragment when making custom DataTable columns.  You could create a new
fragment that has the link that will call your service method to return the
pdf for the provided row model.  So in your column definition in
populateItem, you do something like:

cellItem.add(new PdfLinkFragment(componentId, fragmentId, YourPage.class,
cellItem.getModel());

And define PdfLinkFragment to extend Fragment.  This fragment would have
your link defined for the provided model.

I hope this makes sense, I'm not in a place where I can give more detailed
code right now.

Alternatively, you could just create a PdfLinkPanel and add that to the
cellItem instead of using a fragment.  Both options would accomplish the
same thing.

If you need to put the link in the header column, you'll probably have to
do some subclassing of FilteredAbstractColumn and probably make your own
header bar.

On Sun, Jun 3, 2012 at 8:15 AM, lang <de...@telfort.nl> wrote:

> Hi, in my datatable i use different columns with filters. One of those
> columns contain a invoice number
> I want to show a pdf if a user click this row
>
> Example
> Order      invoice
> <input> <input>
> 1001      123401    <--- This column must be clicable. After click it must
> open a pdf with 123401.pdf
> Who can help?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Need-a-link-in-a-dataview-filter-column-tp4649688.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>