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);
    }
}

Reply via email to