From 2968a09613cf5f9bbb46db77339df54a37e0bf13 Mon Sep 17 00:00:00 2001 From: bdc34 Date: Tue, 27 Jul 2010 14:44:16 +0000 Subject: [PATCH] merge to trunk. Fixing exceptions on submission of null value in dataproperty form. NIHVIVO-1021 --- webapp/web/edit/processDatapropRdfForm.jsp | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/webapp/web/edit/processDatapropRdfForm.jsp b/webapp/web/edit/processDatapropRdfForm.jsp index ee023951c..8df1f9b9c 100644 --- a/webapp/web/edit/processDatapropRdfForm.jsp +++ b/webapp/web/edit/processDatapropRdfForm.jsp @@ -292,15 +292,17 @@ and set a flag in the request to indicate "back button confusion" DataPropertyStatement dps = new DataPropertyStatementImpl(); Literal submitted = submission.getLiteralsFromForm().get(copy.getVarNameForObject()); - dps.setIndividualURI( copy.getSubjectUri() ); - dps.setDatapropURI( copy.getPredicateUri() ); - dps.setDatatypeURI( submitted.getDatatypeURI()); - dps.setLanguage( submitted.getLanguage() ); - dps.setData( submitted.getLexicalForm() ); + if( submitted != null ){ + dps.setIndividualURI( copy.getSubjectUri() ); + dps.setDatapropURI( copy.getPredicateUri() ); + dps.setDatatypeURI( submitted.getDatatypeURI()); + dps.setLanguage( submitted.getLanguage() ); + dps.setData( submitted.getLexicalForm() ); - copy.prepareForDataPropUpdate(writeModel, dps); - copy.setDatapropKey( Integer.toString(RdfLiteralHash.makeRdfLiteralHash(dps)) ); - EditConfiguration.putConfigInSession(copy,session); + copy.prepareForDataPropUpdate(writeModel, dps); + copy.setDatapropKey( Integer.toString(RdfLiteralHash.makeRdfLiteralHash(dps)) ); + EditConfiguration.putConfigInSession(copy,session); + } %> @@ -404,8 +406,11 @@ and set a flag in the request to indicate "back button confusion" String onlyField = editConfig.getFields().keySet().iterator() .next(); Literal value = submission.getLiteralsFromForm().get(onlyField); - if ("".equals(value.getLexicalForm())) { - log.debug("Submission was a single field with an empty string"); + if( value == null ){ + log.debug("No parameters found in submission for field \"" + onlyField +"\""); + return true; + }else if( "".equals(value.getLexicalForm())) { + log.debug("Submission was a single field named \"" + onlyField + "\" with an empty string"); return true; } }