rjy7 2010-07-24 20:25:37 +00:00
parent 826679b073
commit 2be346ee67
3 changed files with 33 additions and 13 deletions

View file

@ -212,6 +212,11 @@
<required>false</required> <required>false</required>
<rtexprvalue>true</rtexprvalue> <rtexprvalue>true</rtexprvalue>
</attribute> </attribute>
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag> </tag>
</taglib> </taglib>

View file

@ -45,6 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
* in preparation for N3. They may also be appended with a datatype or lang. * in preparation for N3. They may also be appended with a datatype or lang.
*/ */
public class EditConfiguration { public class EditConfiguration {
List<String> n3Required; List<String> n3Required;
List<String> n3Optional; List<String> n3Optional;
List<String> urisOnform; List<String> urisOnform;
@ -254,15 +255,15 @@ public class EditConfiguration {
UserToIndIdentifierFactory.getIndividualsForUser(ids); UserToIndIdentifierFactory.getIndividualsForUser(ids);
if( userUris == null || userUris.size() == 0 ){ if( userUris == null || userUris.size() == 0 ){
System.out.println("Cound not find user ur for edit request"); log.debug("Cound not find user ur for edit request");
log.error("Could not find a userUri for edit request, make " + log.error("Could not find a userUri for edit request, make " +
"sure that there is an IdentifierBundleFactory that " + "sure that there is an IdentifierBundleFactory that " +
"produces userUri identifiers in the context."); "produces userUri identifiers in the context.");
} else if( userUris.size() > 1 ){ } else if( userUris.size() > 1 ){
log.error("Found multiple userUris, using the first in list."); log.error("Found multiple userUris, using the first in list.");
System.out.println("Found multiple user uris"); log.debug("Found multiple user uris");
}else { }else {
System.out.println("EditConfiguration.java - checking system value for User URI " + userUris.get(0)); log.debug("EditConfiguration.java - checking system value for User URI " + userUris.get(0));
getUrisInScope().put("editingUser",userUris.get(0)); getUrisInScope().put("editingUser",userUris.get(0));
} }
} }
@ -304,24 +305,24 @@ public class EditConfiguration {
public void prepareForObjPropUpdate( Model model ){ public void prepareForObjPropUpdate( Model model ){
if( model == null ) { if( model == null ) {
//Added parens and output //Added parens and output
System.out.println("Model is null and will be throwing an error"); log.debug("Model is null and will be throwing an error");
throw new Error("EditConfiguration.prepareForObjPropUpdate() needs a Model");} throw new Error("EditConfiguration.prepareForObjPropUpdate() needs a Model");}
if( !isObjectResource ) if( !isObjectResource )
{ {
//Added parens and output //Added parens and output
System.out.println("This is not an object resource? lacks dataprop "); log.debug("This is not an object resource? lacks dataprop ");
throw new Error("This request does not appear to be for an update since it lacks a dataprop object or a dataProp hash key "); throw new Error("This request does not appear to be for an update since it lacks a dataprop object or a dataProp hash key ");
} }
//find the variable for object, this anchors the paths to the existing values //find the variable for object, this anchors the paths to the existing values
if( object == null || object.trim().length() == 0) if( object == null || object.trim().length() == 0)
{ {
//Added parens and output //Added parens and output
System.out.println("Object is null or object length is null"); log.debug("Object is null or object length is null");
throw new Error("This request does not appear to be for an update since it lacks an object"); throw new Error("This request does not appear to be for an update since it lacks an object");
} }
getUrisInScope().put( varNameForObject, object); getUrisInScope().put( varNameForObject, object);
System.out.println("Putting uris in scope - var name for ojbect " + varNameForObject + " and object is " + object); log.debug("Putting uris in scope - var name for object " + varNameForObject + " and object is " + object);
// run SPARQL, sub in values // run SPARQL, sub in values
SparqlEvaluate sparqlEval = new SparqlEvaluate( model ); SparqlEvaluate sparqlEval = new SparqlEvaluate( model );
runSparqlForAdditional( sparqlEval ); runSparqlForAdditional( sparqlEval );

View file

@ -65,6 +65,7 @@ public class InputElementFormattingTag extends TagSupport {
private String cancelUrl; private String cancelUrl;
private String cssClass; private String cssClass;
private String labelClass; private String labelClass;
private String disabled;
private String value; private String value;
private String error; private String error;
private int size = 0; private int size = 0;
@ -122,14 +123,18 @@ public class InputElementFormattingTag extends TagSupport {
public void setCssClass(String classStr) { public void setCssClass(String classStr) {
this.cssClass = classStr; this.cssClass = classStr;
} }
public String getLabelClass() { public String getLabelClass() {
return labelClass; return labelClass;
} }
public void setLabelClass(String labelClassStr) { public void setLabelClass(String labelClassStr) {
this.labelClass = labelClassStr; this.labelClass = labelClassStr;
} }
public String getDisabled() {
return disabled;
}
public void setDisabled(String disabled) {
this.disabled = disabled;
}
public String getValue() { public String getValue() {
return value; return value;
} }
@ -209,6 +214,15 @@ public class InputElementFormattingTag extends TagSupport {
return ""; return "";
} }
private String doDisabled() {
/* only insert the disabled attribute if it has been populated */
String disabled = getDisabled();
if (!StringUtils.isEmpty(disabled)) {
return "disabled=\"disabled\"";
}
return "";
}
private String doSize() { private String doSize() {
if (getSize()>0) { if (getSize()>0) {
return "size=\"" + getSize() + "\""; return "size=\"" + getSize() + "\"";
@ -283,7 +297,6 @@ public class InputElementFormattingTag extends TagSupport {
return ""; return "";
} }
private String literalToString(Literal lit){ private String literalToString(Literal lit){
if( lit == null || lit.getValue() == null) return ""; if( lit == null || lit.getValue() == null) return "";
String value = lit.getValue().toString(); String value = lit.getValue().toString();
@ -394,6 +407,7 @@ public class InputElementFormattingTag extends TagSupport {
/* populate the pieces */ /* populate the pieces */
String classStr = doClass(); String classStr = doClass();
String disabledStr = doDisabled();
String errorStr = getValidationErrors(editSub); String errorStr = getValidationErrors(editSub);
JspWriter out = pageContext.getOut(); JspWriter out = pageContext.getOut();
@ -445,7 +459,7 @@ public class InputElementFormattingTag extends TagSupport {
String valueStr = doValue(editConfig, editSub); String valueStr = doValue(editConfig, editSub);
String sizeStr = doSize(); String sizeStr = doSize();
if (definitionTags) { out.print("<dd>"); } if (definitionTags) { out.print("<dd>"); }
out.print("<input "+classStr+" "+sizeStr+" type=\"text\" id=\""+getId()+"\" name=\""+getName()+"\" value=\""+valueStr+"\" />"); out.print("<input "+classStr+" "+sizeStr+" " + disabledStr + " type=\"text\" id=\""+getId()+"\" name=\""+getName()+"\" value=\""+valueStr+"\" />");
if (definitionTags) { out.print("</dd>"); } if (definitionTags) { out.print("</dd>"); }
out.println(); out.println();
// Handle hidden inputs where Javascript writes a value that needs to be returned with an invalid submission. // Handle hidden inputs where Javascript writes a value that needs to be returned with an invalid submission.
@ -473,9 +487,9 @@ public class InputElementFormattingTag extends TagSupport {
if (optionsMap.size()>0) { // e.g., an Educational Background where may be no choices left after remove existing if (optionsMap.size()>0) { // e.g., an Educational Background where may be no choices left after remove existing
if (definitionTags) { out.print("<dd>"); } if (definitionTags) { out.print("<dd>"); }
if (multiple!=null && !multiple.equals("")) { if (multiple!=null && !multiple.equals("")) {
out.print("<select "+classStr+" id=\""+getId()+"\" name=\""+getName()+"\" multiple=\"multiple\" size=\""+(optionsMap.size() > 10? "10" : optionsMap.size())+"\">"); out.print("<select "+ classStr+ " " + disabledStr + " id=\""+getId()+"\" name=\""+getName()+"\" multiple=\"multiple\" size=\""+(optionsMap.size() > 10? "10" : optionsMap.size())+"\">");
} else { } else {
out.print("<select "+classStr+" id=\""+getId()+"\" name=\""+getName()+"\">"); out.print("<select "+classStr+ " " + disabledStr + " id=\""+getId()+"\" name=\""+getName()+"\">");
} }
Field thisField = editConfig.getField(getName()); Field thisField = editConfig.getField(getName());