[DS-1489] Back button in Discovery broken in Firefox

This commit is contained in:
KevinVdV
2013-06-20 18:26:38 +02:00
committed by Andrea Bollini
parent 90c86da2ac
commit b3aca64759
6 changed files with 40 additions and 30 deletions

View File

@@ -208,13 +208,17 @@ public abstract class AbstractSearch extends AbstractDSpaceTransformer implement
*/
protected void buildMainForm(Division searchDiv) throws WingException, SQLException {
Request request = ObjectModelHelper.getRequest(objectModel);
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
//We set our action to context path, since the eventual action will depend on which url we click on
Division mainForm = searchDiv.addInteractiveDivision("main-form", getBasicUrl(), Division.METHOD_POST, "");
String query = getQuery();
//Indicate that the form we are submitting lists search results
mainForm.addHidden("search-result").setValue(Boolean.TRUE.toString());
mainForm.addHidden("query").setValue(query);
mainForm.addHidden("current-scope").setValue(dso == null ? "" : dso.getHandle());
Map<String, String[]> fqs = getParameterFilterQueries();
if (fqs != null)
{
@@ -245,7 +249,6 @@ public abstract class AbstractSearch extends AbstractDSpaceTransformer implement
{
order.setValue(request.getParameter("order"));
}else{
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(dso);
order.setValue(discoveryConfiguration.getSearchSortConfiguration().getDefaultSortOrder().toString());
}
@@ -253,8 +256,6 @@ public abstract class AbstractSearch extends AbstractDSpaceTransformer implement
{
mainForm.addHidden("page").setValue(request.getParameter("page"));
}
//Optional redirect url !
mainForm.addHidden("redirectUrl");
}
protected abstract String getBasicUrl() throws SQLException;

View File

@@ -42,11 +42,13 @@ public class SearchResultLogAction extends AbstractAction {
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
Context context = ContextUtil.obtainContext(objectModel);
DSpaceObject scope = HandleUtil.obtainHandle(objectModel);
DSpaceObject result = HandleUtil.obtainHandle(objectModel);
String redirectUrl = request.getParameter("redirectUrl");
String resultHandle = StringUtils.substringAfter(redirectUrl, "/handle/");
DSpaceObject result = HandleManager.resolveToObject(ContextUtil.obtainContext(request), resultHandle);
DSpaceObject scope = null;
if(StringUtils.isNotBlank(request.getParameter("current-scope")))
{
scope = HandleManager.resolveToObject(context, request.getParameter("current-scope"));
}
//Fire an event to log our search result
UsageSearchEvent searchEvent = new UsageSearchEvent(
@@ -72,9 +74,6 @@ public class SearchResultLogAction extends AbstractAction {
new DSpace().getEventService().fireEvent(
searchEvent);
HttpServletResponse httpResponse = (HttpServletResponse) objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
httpResponse.sendRedirect(redirectUrl);
return new HashMap();
}
}

View File

@@ -47,10 +47,18 @@ public class StatisticsSearchResultTransformer extends AbstractDSpaceTransformer
if(scope != null){
formUrl.append("/handle/").append(scope.getHandle());
}
formUrl.append("/dso-display");
if(parameters.getParameterAsBoolean("advanced-search", false))
{
formUrl.append("/advanced-search");
} else {
formUrl.append("/search");
}
Division mainForm = body.addInteractiveDivision("dso-display", formUrl.toString(), Division.METHOD_POST, "");
mainForm.addHidden("current-scope").setValue(scope == null ? "" : scope.getHandle());
//Indicate that the form we are submitting lists search results
mainForm.addHidden("search-result").setValue(Boolean.TRUE.toString());
mainForm.addHidden("query").setValue(getQuery());
if(!StringUtils.isBlank(request.getParameter("rpp"))){
mainForm.addHidden("rpp").setValue(Integer.parseInt(request.getParameter("rpp")));
@@ -64,10 +72,6 @@ public class StatisticsSearchResultTransformer extends AbstractDSpaceTransformer
if(!StringUtils.isBlank(request.getParameter("page"))){
mainForm.addHidden("page").setValue(Integer.parseInt(request.getParameter("page")));
}
//This hidden input will contain the resulting url to which we redirect once our work has been completed
mainForm.addHidden("redirectUrl");
}
private String getQuery() throws UIException {

View File

@@ -183,12 +183,6 @@
</map:match>
</map:match>
<map:match pattern="dso-display">
<map:act type="SearchResultLogAction"/>
</map:match>
<map:match pattern="search">
<map:transform type="IncludePageMeta">
<map:parameter name="javascript.static.statistics#1" value="loadJQuery.js"/>
@@ -227,14 +221,27 @@
<!-- Handle specific features -->
<map:match pattern="handle/*/**">
<!-- Logging in case of a search result -->
<map:match pattern="handle/*/*">
<!-- Make sure we have a search result by checking the parameter -->
<map:match type="request-parameter" pattern="search-result">
<map:match type="HandleAuthorizedMatcher" pattern="READ">
<map:match type="HandleTypeMatcher" pattern="community">
<map:act type="SearchResultLogAction"/>
</map:match>
<map:match type="HandleTypeMatcher" pattern="collection">
<map:act type="SearchResultLogAction"/>
</map:match>
<map:match type="HandleTypeMatcher" pattern="item">
<map:act type="SearchResultLogAction"/>
</map:match>
</map:match>
</map:match>
</map:match>
<!-- Scoped browse by features -->
<map:match type="HandleAuthorizedMatcher" pattern="READ">
<map:match type="HandleTypeMatcher" pattern="community,collection">
<map:match pattern="handle/*/*/dso-display">
<map:act type="SearchResultLogAction"/>
</map:match>
<!-- Simple search -->
<map:match pattern="handle/*/*/search">
<map:transform type="IncludePageMeta">
@@ -282,8 +289,8 @@
<!-- End match handle/*/** -->
<map:serialize type="xml"/>
<map:serialize type="xml"/>
</map:pipeline>
</map:pipeline>
</map:pipelines>
</map:sitemap>

View File

@@ -19,10 +19,9 @@
//Instead of redirecting us to the page, first send us to the statistics logger
//By doing this we ensure that we register the query to the result
var form = $('form#aspect_discovery_SimpleSearch_div_main-form');
form.attr('action', form.attr('action').replace('/discover', '') + '/dso-display');
form.attr('action', $this.attr('href'));
//Manipulate the fq boxes to all switch to query since the logging doesn't take into account filter queries
form.find('input[name="fq"]').attr('name', 'query');
form.find('input[name="redirectUrl"]').val($this.attr('href'));
form.submit();
return false;
});

View File

@@ -22,7 +22,7 @@
//Instead of redirecting us to the page, first send us to the statistics logger
//By doing this we ensure that we register the query to the result
var form = $('form#aspect_statistics_StatisticsSearchResultTransformer_div_dso-display');
form.find('input[name="redirectUrl"]').val($this.attr('href'));
form.attr('action', $this.attr('href'));
form.submit();
return false;
});