NIHVIVO-646 Add cancelUrl parameter to submit tag in InputElementFormattingTags so that the cancel button can redirect to a different page from the form submission. Change cancel values in submit tags in vitro and vivo forms to "true" where previously they specified a uri, because the uri is misleading (it doesn't control the redirect location). Removed edit submission preprocessing due to problems with cloning.
This commit is contained in:
parent
cbe3f24250
commit
97a753b66e
17 changed files with 76 additions and 52 deletions
|
@ -148,20 +148,15 @@
|
|||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>cancelLabel</name>
|
||||
<name>labelClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>cssClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>labelClass</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>value</name>
|
||||
<required>false</required>
|
||||
|
@ -201,7 +196,17 @@
|
|||
<name>cancel</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>cancelLabel</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>cancelUrl</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
</tag>
|
||||
|
||||
</taglib>
|
|
@ -29,7 +29,7 @@ import com.hp.hpl.jena.vocabulary.XSD;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
||||
|
||||
public class EditSubmission implements Cloneable {
|
||||
public class EditSubmission {
|
||||
private String editKey;
|
||||
|
||||
private Map<String,Literal> literalsFromForm ;
|
||||
|
@ -413,16 +413,6 @@ public class EditSubmission implements Cloneable {
|
|||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public EditSubmission clone() {
|
||||
try {
|
||||
return (EditSubmission) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.error("Error cloning EditSubmission object: CloneNotSupported exception");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Log log = LogFactory.getLog(EditSubmission.class);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.SelectListGenerator;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* This tag will build an option list for individuals of a VClass.
|
||||
|
@ -56,6 +57,7 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
private String type;
|
||||
private String label;
|
||||
private String cancelLabel;
|
||||
private String cancelUrl;
|
||||
private String cssClass;
|
||||
private String labelClass;
|
||||
private String value;
|
||||
|
@ -96,6 +98,12 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
public void setCancelLabel(String cancelLabel) {
|
||||
this.cancelLabel = cancelLabel;
|
||||
}
|
||||
public String getCancelUrl() {
|
||||
return cancelUrl;
|
||||
}
|
||||
public void setCancelUrl(String cancelUrl) {
|
||||
this.cancelUrl = cancelUrl;
|
||||
}
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
@ -295,12 +303,19 @@ public class InputElementFormattingTag extends TagSupport {
|
|||
}else if( "dashboard".equals( getCancel() )){ //this case is Datastar-specific.
|
||||
return " or <a class=\"cancel\" href=\"" + vreq.getContextPath()
|
||||
+ "/dashboard\" title=\"Cancel\">"+labelStr+"</a>";
|
||||
}else if (getCancel()!=null && !getCancel().equals("")) {
|
||||
}else if (getCancel()!=null && !getCancel().equals("") && !getCancel().equals("false")) {
|
||||
if( editConfig != null && editConfig.getEditKey() != null ){
|
||||
try{
|
||||
return "<span class=\"or\"> or </span><a class=\"cancel\" href=\"" + vreq.getContextPath()
|
||||
+ "/edit/postEditCleanUp.jsp?editKey="+ URLEncoder.encode(editConfig.getEditKey(),"UTF-8")
|
||||
+"\" title=\"Cancel\">"+labelStr+"</a>";
|
||||
String url = vreq.getContextPath() +
|
||||
"/edit/postEditCleanUp.jsp?editKey="+
|
||||
URLEncoder.encode(editConfig.getEditKey(),"UTF-8") +
|
||||
"&cancel=true";
|
||||
String cancelUrl = getCancelUrl();
|
||||
if (!StringUtils.isEmpty(cancelUrl)) {
|
||||
url += "&url=" + cancelUrl;
|
||||
}
|
||||
return "<span class=\"or\"> or </span><a class=\"cancel\" href=\"" +
|
||||
url + "\" title=\"Cancel\">"+labelStr+"</a>";
|
||||
}catch(UnsupportedEncodingException ex){
|
||||
log.error( "doCancel(): " , ex);
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ $(document).ready(function() {
|
|||
<hr/>
|
||||
<v:input type="select" label="label (optional)" id="moniker"/> <em>start typing to see existing choices, or add a new label</em>
|
||||
<v:input type="text" label="associated web page (optional)" id="linkUrl" size="50"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitButtonLabel%>" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitButtonLabel%>" cancel="true"/>
|
||||
</form>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
|
@ -129,7 +129,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
<h2>Set Display Visibility</h2>
|
||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
<v:input type="select" id="displayRole" size="80" />
|
||||
<v:input type="submit" id="submit" value="submit" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="submit" cancel="true"/>
|
||||
</form>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
|
@ -171,7 +171,7 @@ $(document).ready(function() {
|
|||
<p class="propEntryHelpText">${predicate.publicDescription}</p>
|
||||
</c:if>
|
||||
<v:input type="select" id="${dataLiteral}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
||||
</form>
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ $(document).ready(function() {
|
|||
<p>${predicate.publicDescription}</p>
|
||||
</c:if>
|
||||
<v:input type="select" id="${objectVar}" size="80" />
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
||||
<c:if test="${predicate.offerCreateNewOption == true}">
|
||||
<p>If you don't find the appropriate entry on the selection list,
|
||||
<button type="button" onclick="javascript:document.location.href='${createNewUrl}'">add a new item to this list</button>
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
<input type="hidden" name="y" value="1"/>
|
||||
<input type="hidden" name="cmd" value="delete"/>
|
||||
<input type="hidden" name="vitroNsProp" value="${param.vitroNsProp}" />
|
||||
<v:input type="submit" id="submit" value="Delete" cancel="${param.subjectUri}" />
|
||||
<v:input type="submit" id="submit" value="Delete" cancel="true" />
|
||||
</form>
|
||||
<jsp:include page="${postForm}"/>
|
||||
<% }
|
||||
|
|
|
@ -249,7 +249,7 @@
|
|||
<h2>${title}</h2>
|
||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" ><br/>
|
||||
<v:input type="text" label="name (required)" id="name" size="30"/><br/>
|
||||
<v:input type="submit" id="submit" value="<%=submitButtonLabel%>" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitButtonLabel%>" cancel="true"/>
|
||||
</form>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
<label for="${dataLiteral}"><p class="propEntryHelpText">${predicate.publicDescription}</p></label>
|
||||
</c:if>
|
||||
<v:input type="textarea" id="${dataLiteral}" rows="2"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
||||
</form>
|
||||
|
||||
<c:if test="${ (!empty param.datapropKey) && (empty param.deleteProhibited) }">
|
||||
|
|
|
@ -204,7 +204,7 @@
|
|||
<v:input type="text" label="URL" id="url" size="70"/>
|
||||
<v:input type="text" label="Link anchor text" id="anchor" size="70"/>
|
||||
<input type="hidden" name="displayRank" value="-1" />
|
||||
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/></p>
|
||||
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/></p>
|
||||
</form>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
</c:if>
|
||||
<v:input type="select" id="objectVar" size="80" />
|
||||
<div style="margin-top: 1em">
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
||||
</div>
|
||||
</form>
|
||||
</c:if>
|
||||
|
|
|
@ -191,7 +191,7 @@
|
|||
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
||||
<v:input type="<%= inputType %>" id="${propertyName}" size="30" />
|
||||
<input type="hidden" name="vitroNsProp" value="true" />
|
||||
<p class="submit"><v:input type="submit" id="submit" value="<%= submitLabel %>" cancel="${param.subjectUri}"/></p>
|
||||
<p class="submit"><v:input type="submit" id="submit" value="<%= submitLabel %>" cancel="true"/></p>
|
||||
</form>
|
||||
|
||||
<c:if test="${ (!empty param.datapropKey) && (empty param.deleteProhibited) }">
|
||||
|
|
|
@ -159,7 +159,7 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
|||
<input type="hidden" name="objectUri" value="${param.objectUri}"/>
|
||||
<input type="hidden" name="y" value="1"/>
|
||||
<input type="hidden" name="cmd" value="delete"/>
|
||||
<p class="submit"><v:input type="submit" id="submit" value="Delete" cancel="${param.subjectUri}" /></p>
|
||||
<p class="submit"><v:input type="submit" id="submit" value="Delete" cancel="true" /></p>
|
||||
|
||||
</form>
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
<h2>Upload a File</h2>
|
||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" ENCTYPE="multipart/form-data" method="POST">
|
||||
File <v:input type="file" id="fileResource" />
|
||||
<v:input type="submit" id="submit" value="submit" cancel="${param.subjectUri}"/>
|
||||
<v:input type="submit" id="submit" value="submit" cancel="true"/>
|
||||
</form>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.StringUtils" %>
|
||||
<%@page import="org.apache.commons.logging.Log"%>
|
||||
<%@page import="org.apache.commons.logging.LogFactory"%>
|
||||
<%@page import="com.hp.hpl.jena.rdf.model.ResourceFactory"%>
|
||||
|
@ -41,13 +42,24 @@
|
|||
}
|
||||
|
||||
//set up base URL
|
||||
if( editConfig == null || editConfig.getUrlPatternToReturnTo() == null){
|
||||
urlPattern = "/individual";
|
||||
}else{
|
||||
urlPattern = editConfig.getUrlPatternToReturnTo();
|
||||
String cancel = request.getParameter("cancel");
|
||||
String urlPatternToReturnTo = null;
|
||||
String urlPatternToCancelTo = null;
|
||||
if (editConfig != null) {
|
||||
urlPatternToReturnTo = editConfig.getUrlPatternToReturnTo();
|
||||
urlPatternToCancelTo = request.getParameter("url");
|
||||
}
|
||||
// If a different cancel return path has been designated, use it. Otherwise, use the regular return path.
|
||||
if (cancel != null && cancel.equals("true") && !StringUtils.isEmpty(urlPatternToCancelTo)) {
|
||||
urlPattern = urlPatternToCancelTo;
|
||||
}
|
||||
else if (!StringUtils.isEmpty(urlPatternToReturnTo)) {
|
||||
urlPattern = urlPatternToReturnTo;
|
||||
} else {
|
||||
urlPattern = "/individual";
|
||||
}
|
||||
|
||||
//looks like a redirec to an profile page, try to add anchor for property that was just edited.
|
||||
//looks like a redirect to a profile page, try to add anchor for property that was just edited.
|
||||
if( urlPattern.endsWith("individual") || urlPattern.endsWith("entity") ){
|
||||
if( predicateLocalName != null && predicateLocalName.length() > 0){
|
||||
predicateAnchor = "#" + predicateLocalName;
|
||||
|
|
|
@ -89,10 +89,12 @@ are well formed.
|
|||
EditSubmission submission = new EditSubmission(queryParameters,editConfig);
|
||||
|
||||
// Preprocess the form submission
|
||||
EditSubmission processedSubmission = submission.clone();
|
||||
for (EditSubmissionPreprocessor preprocessor : editConfig.getEditSubmissionPreprocessors()) {
|
||||
preprocessor.preprocess(processedSubmission);
|
||||
}
|
||||
// RY clone() creates a shallow copy, not a deep copy. To do this, need to implement
|
||||
// a custom clone() method for EditSubmission or a copy constructor.
|
||||
//EditSubmission submission = submission.clone();
|
||||
//for (EditSubmissionPreprocessor preprocessor : editConfig.getEditSubmissionPreprocessors()) {
|
||||
// preprocessor.preprocess(submission);
|
||||
//}
|
||||
|
||||
/* entity to return to may be a variable */
|
||||
List<String> entToReturnTo = new ArrayList<String>(1);
|
||||
|
@ -129,9 +131,9 @@ are well formed.
|
|||
Map<String,List<String>> fieldRetractions= fieldsToRetractionMap(editConfig.getFields());
|
||||
|
||||
/* ********** URIs and Literals on Form/Parameters *********** */
|
||||
fieldAssertions = n3Subber.substituteIntoValues( processedSubmission.getUrisFromForm(), processedSubmission.getLiteralsFromForm(), fieldAssertions);
|
||||
fieldAssertions = n3Subber.substituteIntoValues( submission.getUrisFromForm(), submission.getLiteralsFromForm(), fieldAssertions);
|
||||
if(log.isDebugEnabled()) logAddRetract("substituted in literals from form",fieldAssertions,fieldRetractions);
|
||||
entToReturnTo = n3Subber.subInUris(processedSubmission.getUrisFromForm(),entToReturnTo);
|
||||
entToReturnTo = n3Subber.subInUris(submission.getUrisFromForm(),entToReturnTo);
|
||||
//fieldRetractions does NOT get values from form.
|
||||
|
||||
/* ****************** URIs and Literals in Scope ************** */
|
||||
|
@ -211,14 +213,14 @@ are well formed.
|
|||
|
||||
/* ********** URIs and Literals on Form/Parameters *********** */
|
||||
//sub in resource uris off form
|
||||
n3Required = n3Subber.subInUris(processedSubmission.getUrisFromForm(), n3Required);
|
||||
n3Optional = n3Subber.subInUris(processedSubmission.getUrisFromForm(), n3Optional);
|
||||
n3Required = n3Subber.subInUris(submission.getUrisFromForm(), n3Required);
|
||||
n3Optional = n3Subber.subInUris(submission.getUrisFromForm(), n3Optional);
|
||||
if(log.isDebugEnabled()) logRequiredOpt("substituted in URIs off from ",n3Required,n3Optional);
|
||||
entToReturnTo = n3Subber.subInUris(processedSubmission.getUrisFromForm(), entToReturnTo);
|
||||
entToReturnTo = n3Subber.subInUris(submission.getUrisFromForm(), entToReturnTo);
|
||||
|
||||
//sub in literals from form
|
||||
n3Required = n3Subber.subInLiterals(processedSubmission.getLiteralsFromForm(), n3Required);
|
||||
n3Optional = n3Subber.subInLiterals(processedSubmission.getLiteralsFromForm(), n3Optional);
|
||||
n3Required = n3Subber.subInLiterals(submission.getLiteralsFromForm(), n3Required);
|
||||
n3Optional = n3Subber.subInLiterals(submission.getLiteralsFromForm(), n3Optional);
|
||||
if(log.isDebugEnabled()) logRequiredOpt("substituted in literals off from ",n3Required,n3Optional);
|
||||
|
||||
/* ****************** URIs and Literals in Scope ************** */
|
||||
|
|
Loading…
Add table
Reference in a new issue