You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jp...@mchsi.com on 2009/07/15 23:23:59 UTC
PageableListView Question
I'm trying to populate a PageableListView based on the value selected from a DropDownChoice, but am not sure how to do this. I feel like I'm pretty close, so I've attached what I've done so far with the hopes that someone might be able to lend a hand. My code is as follows:
public class DeclarationsAwaitingRecordingPage extends BaseWebPage {
private static final List<County> COUNTIES = Arrays.asList(County.values());
@SpringBean
private IDeclarationService declarationService;
public class DeclarationsAwaitingRecordingModel extends LoadableDetachableModel {
private County county;
public DeclarationsAwaitingRecordingModel(County county) {
this.county = county;
}
@Override
protected Object load() {
List<NonRecordedDeclarationRecord> declarations =
declarationService.findDeclarationsAwaitingRecording(county);
return declarations;
}
}
public DeclarationsAwaitingRecordingPage() {
super();
add(new Label("reportDate", new SimpleDateFormat("MM/dd/yy").format(new Date())));
Form form = new Form("form", new DeclarationsAwaitingRecordingModel(County.COOK)) {
@Override
protected void onSubmit() {
}
};
PageableListView<Declaration> declarations = new PageableListView(
"declarations", declarationService.findDeclarationsAwaitingRecording(County.COOK), 25) {
@Override
protected void populateItem(ListItem item) {
NonRecordedDeclarationRecord record = (NonRecordedDeclarationRecord) item.getModelObject();
item.add(new Label("decNumber", record.getDeclaration().getTxNumber()));
item.add(new Label("propTransferDate", new SimpleDateFormat("MM//dd/yyyy").format(record.getDeclaration().getPropertyTransferDate().toString())));
item.add(new Label("daysPastDue", record.getDaysPastDue() == null ? "" : record.getDaysPastDue().toString()));
Stamp stamp = record.getStamp();
String stampAuthorizer = null;
String stampNumber = null;
if (stamp != null) {
stampAuthorizer = stamp.getStampPurchaser().getAccount().getName();
stampNumber = stamp.getFraudDetectionNumber();
}
item.add(new Label("stampAuthorizer", stampAuthorizer == null ? "" : stampAuthorizer));
item.add(new Label("stampNumber", stampNumber == null ? "" : stampNumber));
item.add(new CurrencyLabel("countyAmount", record.getCountyAmount()));
item.add(new CurrencyLabel("stateAmount", record.getStateAmount()));
}
};
add(form);
form.add(new DropDownChoice("counties", COUNTIES));
form.add(new PagingNavigator("navigator", declarations));
form.add(declarations);
}
}
Re: PageableListView Question
Posted by Igor Vaynberg <ig...@gmail.com>.
tie the ddc and the listview using a field: ddc writes selection into
the field, listview reads the field when constructing the list. to do
so use models like below:
-igor
public class mypage extends webpage {
private string criteria;
private list getresults() {
// do some search based on criteria field
}
public mypage() {
add(new dropdownchoice("id",new propertymodel(this, "criteria"), ...
add(new pageablelistview("id", new loadabledetachablemodel(new
propertymodel(this, "results"))
On Wed, Jul 15, 2009 at 2:23 PM, <jp...@mchsi.com> wrote:
> I'm trying to populate a PageableListView based on the value selected from a
> DropDownChoice, but am not sure how to do this. I feel like I'm pretty
> close, so I've attached what I've done so far with the hopes that someone
> might be able to lend a hand. My code is as follows:
>
> public class DeclarationsAwaitingRecordingPage extends BaseWebPage {
>
> private static final List<County> COUNTIES =
> Arrays.asList(County.values());
> @SpringBean
>
> private IDeclarationService declarationService;
>
> public class DeclarationsAwaitingRecordingModel extends
> LoadableDetachableModel {
>
> private County county;
>
> public DeclarationsAwaitingRecordingModel(County county) {
> this.county = county;
> }
>
> @Override
> protected Object load() {
> List<NonRecordedDeclarationRecord> declarations =
>
> declarationService.findDeclarationsAwaitingRecording(county);
> return declarations;
> }
> }
>
> public DeclarationsAwaitingRecordingPage() {
> super();
>
> add(new Label("reportDate", new
> SimpleDateFormat("MM/dd/yy").format(new Date())));
>
> Form form = new Form("form", new
> DeclarationsAwaitingRecordingModel(County.COOK)) {
> @Override
> protected void onSubmit() {
> }
>
> };
>
> PageableListView<Declaration> declarations = new PageableListView(
> "declarations",
> declarationService.findDeclarationsAwaitingRecording(County.COOK), 25) {
> @Override
> protected void populateItem(ListItem item) {
> NonRecordedDeclarationRecord record =
> (NonRecordedDeclarationRecord) item.getModelObject();
> item.add(new Label("decNumber",
> record.getDeclaration().getTxNumber()));
> item.add(new Label("propTransferDate", new
> SimpleDateFormat("MM//dd/yyyy").format(record.getDeclaration().getPropertyTransferDate().toString())));
> item.add(new Label("daysPastDue", record.getDaysPastDue() ==
> null ? "" : record.getDaysPastDue().toString()));
>
> Stamp stamp = record.getStamp();
> String stampAuthorizer = null;
> String stampNumber = null;
> if (stamp != null) {
> stampAuthorizer =
> stamp.getStampPurchaser().getAccount().getName();
> stampNumber = stamp.getFraudDetectionNumber();
> }
> item.add(new Label("stampAuthorizer", stampAuthorizer ==
> null ? "" : stampAuthorizer));
> item.add(new Label("stampNumber", stampNumber == null ? "" :
> stampNumber));
> item.add(new CurrencyLabel("countyAmount",
> record.getCountyAmount()));
> item.add(new CurrencyLabel("stateAmount",
> record.getStateAmount()));
> }
>
> };
>
> add(form);
> form.add(new DropDownChoice("counties", COUNTIES));
> form.add(new PagingNavigator("navigator", declarations));
> form.add(declarations);
> }
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org