1 18 package org.apache.beehive.netui.compiler.model; 19 20 import org.apache.beehive.netui.compiler.model.schema.struts11.SetPropertyDocument.SetProperty; 21 import org.apache.beehive.netui.compiler.model.schema.struts11.ExceptionDocument; 22 import org.apache.beehive.netui.compiler.model.validation.ValidatorConstants; 23 import org.apache.beehive.netui.compiler.JpfLanguageConstants; 24 25 public class ExceptionModel 26 extends StrutsElementSupport 27 implements JpfLanguageConstants 28 { 29 private String _type; 30 private String _path; 31 private String _handlerMethod; 32 private String _message; 33 private String _messageKey; 34 private String _handlerClass; 35 private boolean _readonly = false; 36 37 private static final String JPF_EXCEPTION_CONFIG_CLASSNAME = PAGEFLOW_PACKAGE + ".config.PageFlowExceptionConfig"; 38 39 40 protected ExceptionModel( StrutsApp parentApp ) 41 { 42 super( parentApp ); 43 } 44 45 public ExceptionModel( String type, String path, String handlerMethod, String message, 46 String messageKey, StrutsApp parentApp ) 47 { 48 super( parentApp ); 49 50 _type = type; 51 _path = path; 52 _handlerMethod = handlerMethod; 53 _message = message; 54 _messageKey = messageKey; 55 } 56 57 public String getType() 58 { 59 return _type; 60 } 61 62 public void setType( String type ) 63 { 64 _type = type; 65 } 66 67 public String getPath() 68 { 69 return _path; 70 } 71 72 public void setPath( String path ) 73 { 74 _path = path; 75 } 76 77 public String getHandlerMethod() 78 { 79 return _handlerMethod; 80 } 81 82 public void setHandlerMethod( String handlerMethod ) 83 { 84 _handlerMethod = handlerMethod; 85 } 86 87 public String getMessage() 88 { 89 return _message; 90 } 91 92 public void setMessage( String message ) 93 { 94 _message = message; 95 } 96 97 public String getMessageKey() 98 { 99 return _messageKey; 100 } 101 102 public void setMessageKey( String messageKey ) 103 { 104 _messageKey = messageKey; 105 } 106 107 public String getHandlerClass() 108 { 109 return _handlerClass; 110 } 111 112 public void setHandlerClass( String handlerClass ) 113 { 114 _handlerClass = handlerClass; 115 } 116 117 public void writeToXMLBean( ExceptionDocument.Exception xb ) 118 119 { 120 xb.setType( _type ); 121 122 if ( xb.getPath() == null && _path != null ) 123 { 124 boolean relativeToModule = ! _path.startsWith( "/" ); 125 126 if ( relativeToModule ) 127 { 128 xb.setPath( "/" + _path ); } 130 else 131 { 132 xb.setPath( _path ); 133 addSetProperty( xb, "isPathContextRelative", "true" ); 134 } 135 } 136 137 if ( xb.getKey() == null && _messageKey != null ) xb.setKey( _messageKey ); 138 139 if ( _message != null ) addSetProperty( xb, "defaultMessage", _message ); 143 144 if ( xb.getKey() == null ) xb.setKey( _type ); 145 146 if ( xb.getHandler() == null && _handlerMethod != null && _handlerClass == null ) 150 { 151 xb.setHandler( _handlerMethod ); 152 addSetProperty( xb, "isHandlerMethod", "true" ); 153 } 154 155 if ( _readonly ) addSetProperty( xb, "readonly", "true" ); 156 if ( xb.getHandler() == null && _handlerClass != null ) xb.setHandler( _handlerClass ); 157 } 158 159 private void addSetProperty( ExceptionDocument.Exception xb, String propertyName, String propertyValue ) 160 { 161 SetProperty prop = xb.addNewSetProperty(); 162 prop.setProperty( propertyName ); 163 prop.setValue( propertyValue ); 164 if ( xb.getClassName() == null ) xb.setClassName( JPF_EXCEPTION_CONFIG_CLASSNAME ); 165 } 166 167 public boolean isReadonly() 168 { 169 return _readonly; 170 } 171 172 public void setReadonly( boolean readonly ) 173 { 174 _readonly = readonly; 175 } 176 } 177 | Popular Tags |