From cd65eb18b93793b488564ecae6e23b7b0052e703 Mon Sep 17 00:00:00 2001 From: dubtraxis Date: Tue, 21 Oct 2003 19:27:54 +0000 Subject: [PATCH] Fixed DisplayCommand bug that made it impossible to display a term if there query.entry was null. --- .../org/thdl/lex/commands/DisplayCommand.java | 24 +++++++++++++------ src/jsp/jsp/displayEntry.jsp | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/java/org/thdl/lex/commands/DisplayCommand.java b/src/java/org/thdl/lex/commands/DisplayCommand.java index 0343613..92f0be5 100644 --- a/src/java/org/thdl/lex/commands/DisplayCommand.java +++ b/src/java/org/thdl/lex/commands/DisplayCommand.java @@ -64,18 +64,28 @@ public class DisplayCommand extends LexCommand implements Command try { LexQuery query = visit.getQuery(); - if ( null != component ) + if ( component instanceof ITerm ) { - component.populate( req.getParameterMap() ); - query.setQueryComponent( component ); - LexComponentRepository.loadTermByPk( query ); + ITerm term = (ITerm) component; + + if ( null != query.getEntry() && term.getMetaId().equals( query.getEntry().getMetaId() ) ) + { + LexComponentRepository.update( query.getEntry() ); + } + else + { + LexComponentRepository.loadTermByPk( term ); + query.setEntry( term ); + } + + displayHelper.populate( req.getParameterMap() ); + } else { - LexComponentRepository.update( query.getEntry() ); + setNext( "menu.jsp" ); + msg = "The component you were trying to display was not a term."; } - - displayHelper.populate( req.getParameterMap() ); req.setAttribute( LexConstants.MESSAGE_REQ_ATTR, msg ); return next; diff --git a/src/jsp/jsp/displayEntry.jsp b/src/jsp/jsp/displayEntry.jsp index 784eadc..99a1cdd 100644 --- a/src/jsp/jsp/displayEntry.jsp +++ b/src/jsp/jsp/displayEntry.jsp @@ -95,8 +95,8 @@ translations - - | edit options + | +edit options