Changeset 4902


Ignore:
Timestamp:
04/04/14 15:35:41 (11 years ago)
Author:
Twan Goosen
Message:

moved FCS form into separate panel

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

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/RecordPage.html

    r4900 r4902  
    6161                        </li>
    6262                        <li wicket:id="contentSearch">
    63                             <form id="contentSearchForm" wicket:id="fcsForm" method="post" name="fcsForm" target="_blank" action="[Aggregator endpoint]">
    64                                 <fieldset style="border:0px;">
    65                                     <input type="hidden" name="query" id="query" value="" />
    66                                     <input wicket:id="aggregationContent" type="hidden" name="x-aggregation-context" value='[Endpoint/ID JSON]' />
    67                                     <input type="hidden" name="operation" value="searchRetrieve" />
    68                                     <input type="hidden" name="version" value="1.2" />
    69                                 </fieldset>
    70                             </form>
    71                             <a href="#" onclick="document.fcsForm.submit();">Plain text search via Federated Content Search</a>
     63                            <wicket:container wicket:id="fcsForm">[FCS form]</wicket:container>
    7264                        </li>
    7365                    </ul>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/RecordPage.java

    r4900 r4902  
    1818
    1919import eu.clarin.cmdi.vlo.FacetConstants;
    20 import eu.clarin.cmdi.vlo.config.VloConfig;
    2120import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
    2221import eu.clarin.cmdi.vlo.pojo.SearchContext;
     
    3332import eu.clarin.cmdi.vlo.wicket.panels.BreadCrumbPanel;
    3433import eu.clarin.cmdi.vlo.wicket.panels.PermaLinkPanel;
     34import eu.clarin.cmdi.vlo.wicket.panels.record.ContentSearchFormPanel;
    3535import eu.clarin.cmdi.vlo.wicket.panels.record.FieldsTablePanel;
    3636import eu.clarin.cmdi.vlo.wicket.panels.record.RecordNavigationPanel;
     
    3838import eu.clarin.cmdi.vlo.wicket.provider.DocumentFieldsProvider;
    3939import org.apache.solr.common.SolrDocument;
    40 import org.apache.wicket.AttributeModifier;
    4140import org.apache.wicket.Component;
    4241import org.apache.wicket.RestartResponseException;
    4342import org.apache.wicket.Session;
    4443import org.apache.wicket.ajax.AjaxRequestTarget;
    45 import org.apache.wicket.ajax.json.JSONArray;
    46 import org.apache.wicket.ajax.json.JSONException;
    47 import org.apache.wicket.ajax.json.JSONObject;
    4844import org.apache.wicket.markup.html.WebMarkupContainer;
    4945import org.apache.wicket.markup.html.basic.Label;
     
    6561
    6662    @SpringBean
    67     private VloConfig vloConfig;
    68     @SpringBean
    6963    private PageParametersConverter<QueryFacetsSelection> selectionParametersConverter;
    7064    @SpringBean(name = "basicPropertiesFilter")
     
    209203                    @Override
    210204                    protected void populateItem(ListItem<String> item) {
    211                         try {
    212                             item.add(createContentSearchForm("fcsForm", item.getModel()));
    213                         } catch (JSONException ex) {
    214                             //TODO: handle gracefully?
    215                             throw new RuntimeException(ex);
    216                         }
    217                     }
    218 
    219                     private WebMarkupContainer createContentSearchForm(String id, IModel<String> endpointModel) throws JSONException {
    220                         // Prepare a JSON object that holds the CQL endpoint and the document ID
    221                         final JSONObject json = new JSONObject();
    222                         final String endPoint = endpointModel.getObject();
    223                         final Object docId = RecordPage.this.getModel().getObject().getFirstValue(FacetConstants.FIELD_ID);
    224                         json.put(endPoint, new JSONArray(new Object[]{docId}));
    225 
    226                         // Populate attributes in submit form...
    227                         final WebMarkupContainer fcsForm = new WebMarkupContainer(id);
    228                         // The action of the form should be the aggregator endpoint
    229                         fcsForm.add(new AttributeModifier("action", vloConfig.getFederatedContentSearchUrl()));
    230 
    231                         final WebMarkupContainer aggregationContext = new WebMarkupContainer("aggregationContent");
    232                         // The value of the aggregation context hidden form field should be the JSON object
    233                         aggregationContext.add(new AttributeModifier("value", json.toString(2)));
    234                         fcsForm.add(aggregationContext);
    235 
    236                         return fcsForm;
     205                        item.add(new ContentSearchFormPanel("fcsForm", RecordPage.this.getModel(), item.getModel()));
    237206                    }
    238207                });
Note: See TracChangeset for help on using the changeset viewer.