Revision: 1781
Author: [email protected]
Date: Fri Dec 11 13:44:43 2009
Log: Add basic "tabs" for filtering people by the first letter of their
name. Fixes issue 242.
http://code.google.com/p/simal/source/detail?r=1781
Modified:
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.html
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/panel/PersonListPanel.html
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/panel/PersonListPanel.java
=======================================
---
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.html
Mon Nov 9 22:35:54 2009
+++
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.html
Fri Dec 11 13:44:43 2009
@@ -26,6 +26,33 @@
<body>
<wicket:extend>
+ <p>
+ <a wicket:id="filterWithALink"
href="javascript:document.personFilterForm.submit()">A</a> |
+ <a wicket:id="filterWithBLink"
href="javascript:document.personFilterForm.submit()">B</a> |
+ <a wicket:id="filterWithCLink"
href="javascript:document.personFilterForm.submit()">C</a> |
+ <a wicket:id="filterWithDLink"
href="javascript:document.personFilterForm.submit()">D</a> |
+ <a wicket:id="filterWithELink"
href="javascript:document.personFilterForm.submit()">E</a> |
+ <a wicket:id="filterWithFLink"
href="javascript:document.personFilterForm.submit()">F</a> |
+ <a wicket:id="filterWithGLink"
href="javascript:document.personFilterForm.submit()">G</a> |
+ <a wicket:id="filterWithHLink"
href="javascript:document.personFilterForm.submit()">H</a> |
+ <a wicket:id="filterWithILink"
href="javascript:document.personFilterForm.submit()">I</a> |
+ <a wicket:id="filterWithJLink"
href="javascript:document.personFilterForm.submit()">J</a> |
+ <a wicket:id="filterWithKLink"
href="javascript:document.personFilterForm.submit()">K</a> |
+ <a wicket:id="filterWithLLink"
href="javascript:document.personFilterForm.submit()">L</a> |
+ <a wicket:id="filterWithMLink"
href="javascript:document.personFilterForm.submit()">M</a> |
+ <a wicket:id="filterWithNLink"
href="javascript:document.personFilterForm.submit()">N</a> |
+ <a wicket:id="filterWithOLink"
href="javascript:document.personFilterForm.submit()">O</a> |
+ <a wicket:id="filterWithPLink"
href="javascript:document.personFilterForm.submit()">P</a> |
+ <a wicket:id="filterWithQLink"
href="javascript:document.personFilterForm.submit()">Q</a> |
+ <a wicket:id="filterWithRLink"
href="javascript:document.personFilterForm.submit()">R</a> |
+ <a wicket:id="filterWithSLink"
href="javascript:document.personFilterForm.submit()">S</a> |
+ <a wicket:id="filterWithTLink"
href="javascript:document.personFilterForm.submit()">T</a> |
+ <a wicket:id="filterWithULink"
href="javascript:document.personFilterForm.submit()">U</a> |
+ <a wicket:id="filterWithVLink"
href="javascript:document.personFilterForm.submit()">V</a> |
+ <a wicket:id="filterWithWLink"
href="javascript:document.personFilterForm.submit()">W</a> |
+ <a wicket:id="filterWithXYZLink"
href="javascript:document.personFilterForm.submit()">XYZ</a>
+ </p>
+
<span wicket:id="personList">Person List</span>
</wicket:extend>
</body>
=======================================
---
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
Mon Nov 9 22:35:54 2009
+++
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
Fri Dec 11 13:44:43 2009
@@ -16,6 +16,9 @@
* under the License. *
*/
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+
import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
import uk.ac.osswatch.simal.wicket.BasePage;
import uk.ac.osswatch.simal.wicket.ErrorReportPage;
@@ -30,14 +33,61 @@
public class PersonBrowserPage extends BasePage {
public PersonBrowserPage() {
- try {
- add(new PersonListPanel("personList", "People", 15));
- } catch (SimalRepositoryException e) {
- UserReportableException error = new UserReportableException(
- "Unable to get people from the repository",
- PersonBrowserPage.class, e);
- setResponsePage(new ErrorReportPage(error));
- }
+ populatePage("");
+ }
+
+ /**
+ * Create a new project list page using the supplied parameters. Legal
parameters are:
+ *
+ * <ul>
+ * <li>filter: a filter to be applied</li>
+ * </ul>
+ *
+ * @param parameters
+ */
+ public PersonBrowserPage(PageParameters parameters) {
+ if (parameters.containsKey("filter")) {
+ populatePage(parameters.getString("filter"));
+ } else {
+ UserReportableException error = new UserReportableException(
+ "Invalid parameters", PersonListPage.class);
+ setResponsePage(new ErrorReportPage(error));
+ }
+ }
+
+ public void populatePage(String filter) {
+ try {
+ add(new PersonListPanel("personList", "People", 15,
filter));
+
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithALink",
PersonBrowserPage.class, new PageParameters("filter=^a(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithBLink",
PersonBrowserPage.class, new PageParameters("filter=^b(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithCLink",
PersonBrowserPage.class, new PageParameters("filter=^c(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithDLink",
PersonBrowserPage.class, new PageParameters("filter=^d(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithELink",
PersonBrowserPage.class, new PageParameters("filter=^e(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithFLink",
PersonBrowserPage.class, new PageParameters("filter=^f(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithGLink",
PersonBrowserPage.class, new PageParameters("filter=^g(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithHLink",
PersonBrowserPage.class, new PageParameters("filter=^h(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithILink",
PersonBrowserPage.class, new PageParameters("filter=^i(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithJLink",
PersonBrowserPage.class, new PageParameters("filter=^j(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithKLink",
PersonBrowserPage.class, new PageParameters("filter=^k(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithLLink",
PersonBrowserPage.class, new PageParameters("filter=^l(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithMLink",
PersonBrowserPage.class, new PageParameters("filter=^m(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithNLink",
PersonBrowserPage.class, new PageParameters("filter=^n(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithOLink",
PersonBrowserPage.class, new PageParameters("filter=^o(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithPLink",
PersonBrowserPage.class, new PageParameters("filter=^p(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithQLink",
PersonBrowserPage.class, new PageParameters("filter=^q(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithRLink",
PersonBrowserPage.class, new PageParameters("filter=^r(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithSLink",
PersonBrowserPage.class, new PageParameters("filter=^s(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithTLink",
PersonBrowserPage.class, new PageParameters("filter=^t(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithULink",
PersonBrowserPage.class, new PageParameters("filter=^u(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithVLink",
PersonBrowserPage.class, new PageParameters("filter=^v(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithWLink",
PersonBrowserPage.class, new PageParameters("filter=^w(.*)")));
+ add(new
BookmarkablePageLink<PersonBrowserPage>("filterWithXYZLink",
PersonBrowserPage.class, new PageParameters("filter=^[xyz](.*)")));
+ } catch (SimalRepositoryException e) {
+ UserReportableException error = new
UserReportableException(
+ "Unable to retrieve people to list",
PersonListPage.class);
+ setResponsePage(new ErrorReportPage(error));
+ }
}
}
=======================================
---
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/panel/PersonListPanel.html
Sun Nov 23 08:44:00 2008
+++
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/panel/PersonListPanel.html
Fri Dec 11 13:44:43 2009
@@ -21,7 +21,7 @@
<div class="personList">
<div class="title" wicket:id="title">Person List</div>
- <form wicket:id="personFilterForm">
+ <form wicket:id="personFilterForm" id="personFilterForm">
<p>
<label>Name:</label>
<input type="text" wicket:id="nameFilter" value="" size="50" />
=======================================
---
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/panel/PersonListPanel.java
Tue Oct 27 16:27:44 2009
+++
/trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/panel/PersonListPanel.java
Fri Dec 11 13:44:43 2009
@@ -57,6 +57,7 @@
private static final Logger logger =
LoggerFactory.getLogger(PersonListPanel.class);
private Set<IPerson> people;
private String title;
+ private String filter = "";
private static PersonFilterInputModel inputModel = new
PersonFilterInputModel();
SortablePersonDataProvider dataProvider;
@@ -76,6 +77,27 @@
this.title = title;
this.people = SimalRepositoryFactory.getPersonService().getAll();
populatePanel(numberOfPeople);
+ }
+
+ /**
+ * Create a panel that lists people filtered with a given filter string.
+ *
+ * @param id
+ * the wicket ID for the component
+ * @param title
+ * the title if this list
+ * @param numberOfPeople the number of people to display per page
+ * @param filter the filter to use
+ *
+ * @throws SimalRepositoryException
+ */
+ public PersonListPanel(String id, String title, int numberOfPeople,
String filter)
+ throws SimalRepositoryException {
+ super(id);
+ this.title = title;
+ this.people =
SimalRepositoryFactory.getPersonService().filterByName(filter);
+ this.filter = filter;
+ populatePanel(numberOfPeople);
}
/**
@@ -99,8 +121,8 @@
private void populatePanel(int numberOfPeople) {
add(new Label("title", title));
- add(new PersonFilterForm("personFilterForm"));
- addPersonList(people, numberOfPeople);
+ add(new PersonFilterForm("personFilterForm", this.filter));
+ addPersonList(people, numberOfPeople);
}
@SuppressWarnings("unchecked")
@@ -122,6 +144,8 @@
@Override
public void populateItem(Item cellItem, String componentId, IModel
model) {
+ IPerson person = (IPerson)model.getObject();
+ Set<IInternetAddress> emailSet = person.getEmail();
Iterator<IInternetAddress> emails =
((IPerson)model.getObject()).getEmail().iterator();
if (emails.hasNext()) {
while (emails.hasNext()) {
@@ -140,7 +164,7 @@
} else {
cellItem.add(new Label(componentId, ""));
}
- }
+ }
});
columns.add(new PropertyColumn(new
Model("Project"), "projects", "projects") {
@@ -201,11 +225,11 @@
private static final long serialVersionUID = 4350446873545711199L;
private TextField<String> nameFilter;
- public PersonFilterForm(String name) {
+ public PersonFilterForm(String name, String filter) {
super(name, new
CompoundPropertyModel<PersonFilterInputModel>(inputModel));
nameFilter = new TextField<String>("nameFilter");
add(nameFilter);
- String[] defaultValue = { "" };
+ String[] defaultValue = { filter };
nameFilter.setModelValue(defaultValue);
}
--
You received this message because you are subscribed to the Google Groups
"Simal Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simal-commits?hl=en.