Changeset 4537


Ignore:
Timestamp:
02/20/14 14:24:45 (10 years ago)
Author:
twagoo
Message:

created wrapper model to assign fallback value for null model objects

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/SearchResultsPanel.java

    r4533 r4537  
    2020import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
    2121import eu.clarin.cmdi.vlo.service.SolrDocumentService;
     22import eu.clarin.cmdi.vlo.wicket.model.NullFallbackModel;
    2223import eu.clarin.cmdi.vlo.wicket.model.SolrFieldModel;
    2324import eu.clarin.cmdi.vlo.wicket.provider.SolrDocumentProvider;
     
    5859            @Override
    5960            protected void populateItem(Item<SolrDocument> item) {
    60                 //TODO: Wrap in model to deal with null values
    61                 item.add(new Label("title", new SolrFieldModel(item.getModel(), FacetConstants.FIELD_NAME)));
    62                 item.add(new Label("description", new SolrFieldModel(item.getModel(), FacetConstants.FIELD_DESCRIPTION)));
     61                final IModel<SolrDocument> documentModel = item.getModel();
     62                item.add(new SolrFieldLabel("title", documentModel, FacetConstants.FIELD_NAME));
     63                item.add(new SolrFieldLabel("description", documentModel, FacetConstants.FIELD_DESCRIPTION, "<no description>"));
    6364                //TODO: get resource information
    6465            }
     
    6869    }
    6970
     71    public static class SolrFieldLabel extends Label {
     72
     73        public SolrFieldLabel(String id, IModel<SolrDocument> documentModel, String fieldName) {
     74            super(id, new SolrFieldModel(documentModel, fieldName));
     75        }
     76
     77        public SolrFieldLabel(String id, IModel<SolrDocument> documentModel, String fieldName, String nullFallback) {
     78            super(id,
     79                    new NullFallbackModel(
     80                            new SolrFieldModel(documentModel, fieldName), nullFallback));
     81        }
     82
     83    }
     84
    7085}
Note: See TracChangeset for help on using the changeset viewer.