You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sandor Feher <sf...@bluesystem.hu> on 2012/04/25 15:20:43 UTC

FilterForm Date column formatting

Hi,


I need to add date formater and/or validator to a column in the filterform. 

....
IColumn col_cru=columns.add(new TextFilteredPropertyColumn<HrpContent,
String>(new ResourceModel("contentlisttable.cru"), "cru", "cru"));
....

TIA, Sandor


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4586557.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: FilterForm Date column formatting

Posted by Melinda Dweer <me...@gmail.com>.
Can't use a conditional statement? If filter add panel if not call
super.populateItem?

On Thu, Apr 26, 2012 at 11:36 AM, Sandor Feher <sf...@bluesystem.hu> wrote:

> Hi,
>
> If I do it in this way, then all of my cells in that column will change to
> input textfield. But I only want to change the cell which in the filter
> form
> row.
>
> Regards, Sandor
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589323.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
>
>

[RESOLVED] Re: FilterForm Date column formatting

Posted by Sandor Feher <sf...@bluesystem.hu>.
Hi,

Works fine now :).
Melinda, Martin! Thank you for your help. I really appreciate that!

Just for the archive.

I add a panel overriding the getFilter method.
-----
        IColumn crdCol=new TextFilteredPropertyColumn<HrpContent,
String>(new ResourceModel("contentlisttable.crd"), "crd", "crd") {

            @Override
            public Component getFilter(String componentId, FilterForm<?>
form) {
                return new
DateTextFieldPanel(componentId,getFilterModel(form));
            }
        };  
        columns.add(crdCol);


-----

Here is my panel.

class DateTextFieldPanel extends Panel {

        public DateTextFieldPanel(String id,IModel model) {
            super(id,model);
            DateConverter dc=new DateConverter(true) {

                    @Override
                    public String getDatePattern(Locale locale) {
                        return "yyyy.MM.dd";
                    }

                    @Override
                    protected DateTimeFormatter getFormat(Locale locale) {
                         DateTimeFormatter
fm=DateTimeFormat.forPattern("yyyy.MM.dd");
                         return fm; 
                    }
                };                
            DateTextField dtf =new DateTextField(id,model,dc);            
            add(dtf);            
        }
    }

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589807.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: FilterForm Date column formatting

Posted by Martin Grigorov <mg...@apache.org>.
As Melinda said earlier you need to use a Panel.
The idea is that this way you can use more complex components for
filtering, e.g. from-to dates, a Panel with two date fields.

On Thu, Apr 26, 2012 at 1:26 PM, Sandor Feher <sf...@bluesystem.hu> wrote:
> Ok, np.
> Here is what I did:
>
> ----c----
>
>       IColumn crdCol=new TextFilteredPropertyColumn<HrpContent, String>(new
> ResourceModel("contentlisttable.crd"), "crd", "crd") {
>
>            @Override
>            public Component getFilter(String componentId, FilterForm<?>
> form) {
>                   DateConverter dc=new DateConverter(true) {
>
>                    @Override
>                    public String getDatePattern(Locale locale) {
>                        return "YYYY mm dd";
>                    }
>
>                    @Override
>                    protected DateTimeFormatter getFormat(Locale locale) {
>                         DateTimeFormatter
> fm=DateTimeFormat.forPattern("YYYY mm DD");
>                         return fm;
>                    }
>                };
>                return new DateTextField(componentId,dc);
>            }
>        };
>
> ----c----
>
> Now it complains for this:
>
>
>
> Last cause: Component [filter] (path =
> [5:datatablecontainer:filterForm:datatable:topToolbars:toolbars:3:filters:3:filter])
> must be applied to a tag of type [input], not:  '<td wicket:id="filter"
> class="filter-td">' (line 0, column 0)
>
> Markup
>
> The problem is in
> "jar:file:/X:/mavenrepo/org/apache/wicket/wicket-extensions/1.5.5/wicket-extensions-1.5.5.jar!/org/apache/wicket/extensions/markup/html/repeater/data/table/filter/FilterToolbar.html":
>
> <td wicket:id="filter" class="filter-td">[filter]</td>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589406.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
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: FilterForm Date column formatting

Posted by Sandor Feher <sf...@bluesystem.hu>.
Ok, np.
Here is what I did:

----c----

       IColumn crdCol=new TextFilteredPropertyColumn<HrpContent, String>(new
ResourceModel("contentlisttable.crd"), "crd", "crd") {

            @Override
            public Component getFilter(String componentId, FilterForm<?>
form) {
                   DateConverter dc=new DateConverter(true) {

                    @Override
                    public String getDatePattern(Locale locale) {
                        return "YYYY mm dd";
                    }

                    @Override
                    protected DateTimeFormatter getFormat(Locale locale) {
                         DateTimeFormatter
fm=DateTimeFormat.forPattern("YYYY mm DD");
                         return fm; 
                    }
                };                
                return new DateTextField(componentId,dc);            
            }
        };  

----c----

Now it complains for this:



Last cause: Component [filter] (path =
[5:datatablecontainer:filterForm:datatable:topToolbars:toolbars:3:filters:3:filter])
must be applied to a tag of type [input], not:  '<td wicket:id="filter"
class="filter-td">' (line 0, column 0)

Markup

The problem is in
"jar:file:/X:/mavenrepo/org/apache/wicket/wicket-extensions/1.5.5/wicket-extensions-1.5.5.jar!/org/apache/wicket/extensions/markup/html/repeater/data/table/filter/FilterToolbar.html":

<td wicket:id="filter" class="filter-td">[filter]</td>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589406.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: FilterForm Date column formatting

Posted by Martin Grigorov <mg...@apache.org>.
Sorry, I didn't understand that you want to do that for the filter field.
Override org.apache.wicket.extensions.markup.html.repeater.data.table.filter.TextFilteredPropertyColumn#getFilter()
instead.

On Thu, Apr 26, 2012 at 12:36 PM, Sandor Feher <sf...@bluesystem.hu> wrote:
> Hi,
>
> If I do it in this way, then all of my cells in that column will change to
> input textfield. But I only want to change the cell which in the filter form
> row.
>
> Regards, Sandor
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589323.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
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: FilterForm Date column formatting

Posted by Sandor Feher <sf...@bluesystem.hu>.
Hi,

If I do it in this way, then all of my cells in that column will change to
input textfield. But I only want to change the cell which in the filter form
row.

Regards, Sandor

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589323.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: FilterForm Date column formatting

Posted by Sandor Feher <sf...@bluesystem.hu>.
Ok, I will have try...

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589073.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: FilterForm Date column formatting

Posted by Melinda Dweer <me...@gmail.com>.
I think the problem is  markup for cells is a <span>. You need to create a
panel

<wicket:panel>
       <input wicket:id="dateField"/>
</wicket:panel>

.............. Your date file code ....

and add that panel to table cell.

Regards,

Melinda

On Thu, Apr 26, 2012 at 8:48 AM, Sandor Feher <sf...@bluesystem.hu> wrote:

> Hi,
>
> Yes, sorry for that.
>
> ---------------------------
> Last cause: Component [cell] (path =
> [5:datatablecontainer:filterForm:datatable:body:rows:1:cells:3:cell]) must
> be applied to a tag of type [input], not:  '' (line 0, column 0)
>
> Markup
>
> The problem is in
>
> "jar:file:/X:/mavenrepo/org/apache/wicket/wicket-extensions/1.5.5/wicket-extensions-1.5.5.jar!/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html":
>
> [cell]
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589021.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: FilterForm Date column formatting

Posted by Sandor Feher <sf...@bluesystem.hu>.
Hi,

Yes, sorry for that.

---------------------------
Last cause: Component [cell] (path =
[5:datatablecontainer:filterForm:datatable:body:rows:1:cells:3:cell]) must
be applied to a tag of type [input], not:  '' (line 0, column 0)

Markup

The problem is in
"jar:file:/X:/mavenrepo/org/apache/wicket/wicket-extensions/1.5.5/wicket-extensions-1.5.5.jar!/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html":

[cell]


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4589021.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: FilterForm Date column formatting

Posted by Martin Grigorov <ma...@gmail.com>.
But you don't say what is the problem

Sandor Feher <sf...@bluesystem.hu> wrote:

Hi,

Thank you for the prompt answer. I had a try but it does not work as I
expect.

-------------------
IColumn crdCol=new TextFilteredPropertyColumn<HrpContent, String>(new
ResourceModel("contentlisttable.crd"), "crd", "crd") {

@Override
public void populateItem(Item<ICellPopulator&lt;HrpContent>>
item, String componentId, IModel<HrpContent> rowModel) {
DateConverter dc=new DateConverter(true) {

@Override
public String getDatePattern(Locale locale) {
return "YYYY mm dd";
}

@Override
protected DateTimeFormatter getFormat(Locale locale) {
DateTimeFormatter
fm=DateTimeFormat.forPattern("YYYY mm DD");
return fm; 
}
}; 
item.addOrReplace(new DateTextField(componentId,dc));
}

}; 
columns.add(crdCol);

Rgds, Sandor


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4587855.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: FilterForm Date column formatting

Posted by Sandor Feher <sf...@bluesystem.hu>.
Hi,

Thank you for the prompt answer. I had a try but it does not work as I
expect.

-------------------
IColumn crdCol=new TextFilteredPropertyColumn<HrpContent, String>(new
ResourceModel("contentlisttable.crd"), "crd", "crd") {

            @Override
            public void populateItem(Item<ICellPopulator&lt;HrpContent>>
item, String componentId, IModel<HrpContent> rowModel) {
                DateConverter dc=new DateConverter(true) {

                    @Override
                    public String getDatePattern(Locale locale) {
                        return "YYYY mm dd";
                    }

                    @Override
                    protected DateTimeFormatter getFormat(Locale locale) {
                         DateTimeFormatter
fm=DateTimeFormat.forPattern("YYYY mm DD");
                         return fm; 
                    }
                };                
                item.addOrReplace(new DateTextField(componentId,dc));
            }
            
        };  
        columns.add(crdCol);

Rgds, Sandor


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4587855.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: FilterForm Date column formatting

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

See org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn#populateItem()
You'll need to override that method and add some Date**Field to the item

On Wed, Apr 25, 2012 at 4:20 PM, Sandor Feher <sf...@bluesystem.hu> wrote:
> Hi,
>
>
> I need to add date formater and/or validator to a column in the filterform.
>
> ....
> IColumn col_cru=columns.add(new TextFilteredPropertyColumn<HrpContent,
> String>(new ResourceModel("contentlisttable.cru"), "cru", "cru"));
> ....
>
> TIA, Sandor
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/FilterForm-Date-column-formatting-tp4586557p4586557.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
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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