AjaxFormSubmitBehavior and FilterForm problem
Hi, I have a datatable inside a filterform. Everything works fine but I need to filter table on every single typed characters in my filterform. To achieve this I added an AjaxFormSubmitBehavior to my filterform. There is one small problem with it. If I type one char it works fine but if I type one and another then the first char always get selected and I can't type other chars. How can I get it work ? Regards., Sandor -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxFormSubmitBehavior and FilterForm problem
Hi, It seems the text input field is re-rendered with Ajax after typing a character. Try to not re-render the input field. Or you can use target.appendJavaScript(...) and use something like http://bytes.com/topic/javascript/answers/429209-how-unselect-text-input-box Martin Grigorov Wicket Training and Consulting On Thu, Feb 13, 2014 at 9:00 AM, Sandor Feher sfe...@bluesystem.hu wrote: Hi, I have a datatable inside a filterform. Everything works fine but I need to filter table on every single typed characters in my filterform. To achieve this I added an AjaxFormSubmitBehavior to my filterform. There is one small problem with it. If I type one char it works fine but if I type one and another then the first char always get selected and I can't type other chars. How can I get it work ? Regards., Sandor -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxFormSubmitBehavior and FilterForm problem
Hi Martin, Thanks for the prompt answer. First I try to not re-render filterform's field. How could I do that ? My panel looks like this: I changed target.add from container to table to refresh table only but that did not help. Regards., Sandor -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422p4664427.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxFormSubmitBehavior and FilterForm problem
Do you use org.apache.wicket.extensions.markup.html.repeater.data.table.filter.FilteredPropertyColumn ? Where is the filtering text input field ? Is it in the table ? If YES, then rerendering the table will rerender the input field too. See the JS solution or move the filtering text field out of the table... Martin Grigorov Wicket Training and Consulting On Thu, Feb 13, 2014 at 10:21 AM, Sandor Feher sfe...@bluesystem.hu wrote: Hi Martin, Thanks for the prompt answer. First I try to not re-render filterform's field. How could I do that ? My panel looks like this: I changed target.add from container to table to refresh table only but that did not help. Regards., Sandor -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422p4664427.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxFormSubmitBehavior and FilterForm problem
Yes, I use TextFilteredPropertyColumn and FilterToolbar. So it might better to use js to solve this. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422p4664429.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: AjaxFormSubmitBehavior and FilterForm problem
I implemented a Search for a simple ListView but could be used also for any DataView. This solution also highlights the found String if you add the class 'highlighted' to you CSS. The table part: final WebMarkupContainer table = new WebMarkupContainer(table); table.setOutputMarkupId(true); table.add(new TableBehavior().condensed().striped()); add(table); final TextFieldString searchQuery = new TextFieldString(searchQuery, Model.of()); searchQuery.add(new AjaxFormComponentUpdatingBehavior(onkeyup) { private static final long serialVersionUID = 314186226258079912L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(table); target.appendJavaScript( $('.searchResult').find('td:contains(' + $('.searchQuery').val() + ')').each(function () {\n + $(this).html($(this).html().replace($('.searchQuery').val(), 'span class=\highlighted\' + $('.searchQuery').val() + '/span'));\n + });); } }); add(searchQuery); IModelListActionJournal filteredHistoryEntries = new AbstractReadOnlyModelListActionJournal() { private static final long serialVersionUID = 6375514913998162927L; @Override public ListActionJournal getObject() { if ((searchQuery.getInput() == null) || StringUtils.EMPTY.equals(searchQuery.getInput())) { return model.getObject(); } else { ListActionJournal filtered = model.getObject(); CollectionUtils.filter(filtered, new HistoryFilter(searchQuery.getInput())); return filtered; } } }; ListViewActionJournal historyEntries = new ListViewActionJournal(historyEntries, filteredHistoryEntries) { private static final long serialVersionUID = 389308185477622395L; @Override protected void populateItem(ListItemActionJournal item) { item.setDefaultModel(new CompoundPropertyModelActionJournal(item.getModel())); item.add(new DateLabel(created, new CcaDateConverter())); item.add(new Label(createdByLogin)); item.add(new Label(contactChannel.name)); item.add(new Label(action.name)); item.add(new Label(reason.name)); item.add(new Label(actionText)); } }; table.add(historyEntries); The Predicate for comparsion (you need to replace the evaluation to check for your object fields) private final class HistoryFilter implements Predicate { private final String searchQuery; private HistoryFilter(String searchQuery) { this.searchQuery = searchQuery; } @Override public boolean evaluate(Object object) { if (object instanceof ActionJournal) { ActionJournal entry = (ActionJournal) object; String q = searchQuery.toLowerCase(); if ((entry.getCreatedByLogin() != null) StringUtils.contains(entry.getCreatedByLogin().toLowerCase(), q)) { return true; } else if ((entry.getActionText() != null) StringUtils.contains(entry.getActionText().toLowerCase(), q)) { return true; } else if ((entry.getContactChannel() != null) StringUtils.contains(entry.getContactChannel().getName().toLowerCase(), q)) { return true; } else if ((entry.getAction() != null) StringUtils.contains(entry.getAction().getName().toLowerCase(), q)) { return true; } else if ((entry.getReason() != null) StringUtils.contains(entry.getReason().getName().toLowerCase(), q)) { return true; } } return false; } } Marvin Richter -Original Message- From: Sandor Feher [mailto:sfe...@bluesystem.hu] Sent: Thursday, February 13, 2014 10:45 AM To: users@wicket.apache.org Subject: Re: AjaxFormSubmitBehavior and FilterForm problem Yes, I use TextFilteredPropertyColumn and FilterToolbar. So it might better to use js to solve this. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422p4664429.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
RE: AjaxFormSubmitBehavior and FilterForm problem
Hi, Thanks for the tip. I have almost done it. Just one annoying problem. I can't set filter fields' markup up. Not the td where the input field resides but the input tag itself. I have five filter fields on my filtertoolbar. To use javascript trick I have to set id for every filter fields.(Now wicket set these ids for filter6, filter7 and so one.) Thnx. S -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormSubmitBehavior-and-FilterForm-problem-tp4664422p4664443.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org