[cvs]
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller
ServletControllerResponse.java Transition.java
JCorporate Ltd
jcorp at jcorp2.servlets.net
Mon Sep 20 12:20:31 PDT 2004
Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller
In directory jcorp2.servlets.net:/tmp/cvs-serv750
Modified Files:
ServletControllerResponse.java Transition.java
Log Message:
<Aucun commentaire entré>
Index: Transition.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/Transition.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** Transition.java 18 Sep 2004 00:05:13 -0000 1.54
--- Transition.java 20 Sep 2004 19:20:29 -0000 1.55
***************
*** 123,127 ****
java.io.Serializable {
! private static Logger log = Logger.getLogger("expresso.core.controller.transition");
/**
--- 123,127 ----
java.io.Serializable {
! private static Logger log = Logger.getLogger(Transition.class);
/**
***************
*** 146,150 ****
* re-constructing multiple times.
*/
! private transient String constructedParamString = null;
--- 146,156 ----
* re-constructing multiple times.
*/
! private transient String cacheParamStringSansController = null;
!
! /**
! * This is used to store a constructed parameter string to save on
! * re-constructing multiple times.
! */
! private transient String cacheParamStringWithController = null;
***************
*** 158,162 ****
*/
public Transition() {
- super();
}
--- 164,167 ----
***************
*** 169,173 ****
*/
public Transition(String newState, Controller myController) {
- super();
//
--- 174,177 ----
***************
*** 276,280 ****
*/
public void addParam(String paramCode, String paramValue) {
! constructedParamString = null;
if (paramCode.equals("state")) {
setState(StringUtil.notNull(paramValue));
--- 280,284 ----
*/
public void addParam(String paramCode, String paramValue) {
! clearCache();
if (paramCode.equals("state")) {
setState(StringUtil.notNull(paramValue));
***************
*** 291,294 ****
--- 295,303 ----
} /* addParam(String, String) */
+ private void clearCache() {
+ cacheParamStringWithController = null;
+ cacheParamStringSansController = null;
+ }
+
/**
* Sets the target state to transition to.
***************
*** 297,301 ****
*/
public void setState(String newState) {
! constructedParamString = null;
myState = newState;
}
--- 306,310 ----
*/
public void setState(String newState) {
! clearCache();
myState = newState;
}
***************
*** 444,504 ****
} /* getParams() */
public String getParamString(boolean includeControllerParameter) {
! if (constructedParamString == null) {
FastStringBuffer paramString = FastStringBuffer.getInstance();
try {
! if (controllerObject != null && includeControllerParameter) {
! //Determine if we're transitioning between controllers. If so, then
! //add the controller parameter. If not, then omit it. [Makes for
! //cleaner URLs]
! if (getOwnerController() != null) {
! if (!getOwnerController().equals(getControllerObject())) {
!
! paramString.append("controller=");
! paramString.append(controllerObject);
! }
! } else {
! paramString.append("controller=");
! paramString.append(controllerObject);
! }
}
! if (this.params != null) {
! if (!this.params.isEmpty()) {
! String oneKey = null;
!
! for (Enumeration e = this.params.keys(); e.hasMoreElements();) {
! if (paramString.length() != 0) {
! paramString.append("&");
! }
! oneKey = (String) e.nextElement();
! //Encode user's Transition parameters otherwise is ueer's parameters has '&' then
! //it will mess up the addButtonParams() method when using Tokenizer.
! FastStringBuffer fsb = FastStringBuffer.getInstance();
! try {
! fsb.append(oneKey);
! fsb.append("=");
! fsb.append(URLUTF8Encoder.encode((String) this.params.get(oneKey)));
! paramString.append(fsb.toString());
! } finally {
! fsb.release();
! fsb = null;
! }
! }
! }
! }
! String stateString = StringUtil.notNull(getState());
! if (stateString.length() != 0) {
! if (paramString.length() != 0) {
! paramString.append("&");
! }
! paramString.append("state=");
! paramString.append(stateString);
! }
! constructedParamString = paramString.toString();
} finally {
paramString.release();
--- 453,486 ----
} /* getParams() */
+ /**
+ * @param includeControllerParameter whether to include controller param or not.
+ * @return parameter string which includes all params added to trans, as well
+ * as state param. controller param added optionally
+ */
public String getParamString(boolean includeControllerParameter) {
! if (includeControllerParameter && cacheParamStringWithController == null) {
FastStringBuffer paramString = FastStringBuffer.getInstance();
try {
! if (controllerObject != null ) {
! paramString.append("controller=");
! paramString.append(controllerObject);
}
! addNonControllerParams(paramString);
! cacheParamStringWithController = paramString.toString();
! } finally {
! paramString.release();
! paramString = null;
! }
! }
! if (!includeControllerParameter && cacheParamStringSansController == null) {
! FastStringBuffer paramString = FastStringBuffer.getInstance();
! try {
! addNonControllerParams(paramString);
! cacheParamStringSansController = paramString.toString();
} finally {
paramString.release();
***************
*** 508,515 ****
}
! return constructedParamString;
}
/**
* Return a string of the current params This is NOT URL encoded string.
--- 490,539 ----
}
!
! if ( includeControllerParameter )
! return cacheParamStringWithController;
! else
! return cacheParamStringSansController;
}
+ private void addNonControllerParams(FastStringBuffer paramString) {
+ if (this.params != null) {
+ if (!this.params.isEmpty()) {
+ String oneKey = null;
+
+ for (Enumeration e = this.params.keys(); e.hasMoreElements();) {
+ if (paramString.length() != 0) {
+ paramString.append("&");
+ }
+ oneKey = (String) e.nextElement();
+
+ //Encode user's Transition parameters otherwise is ueer's parameters has '&' then
+ //it will mess up the addButtonParams() method when using Tokenizer.
+ FastStringBuffer fsb = FastStringBuffer.getInstance();
+ try {
+ fsb.append(oneKey);
+ fsb.append("=");
+ fsb.append(URLUTF8Encoder.encode((String) this.params.get(oneKey)));
+ paramString.append(fsb.toString());
+ } finally {
+ fsb.release();
+ fsb = null;
+ }
+
+ }
+ }
+ }
+
+ String stateString = StringUtil.notNull(getState());
+ if (stateString.length() != 0) {
+ if (paramString.length() != 0) {
+ paramString.append("&");
+ }
+ paramString.append("state=");
+ paramString.append(stateString);
+ }
+ }
+
/**
* Return a string of the current params This is NOT URL encoded string.
***************
*** 689,693 ****
*/
public void setControllerObject(String newObject) {
! constructedParamString = null;
controllerObject = newObject;
} /* setControllerObject(String) */
--- 713,717 ----
*/
public void setControllerObject(String newObject) {
! clearCache();
controllerObject = newObject;
} /* setControllerObject(String) */
***************
*** 704,708 ****
*/
public void setControllerObject(Class c) {
! constructedParamString = null;
if (c != null) {
setControllerObject(c.getName());
--- 728,732 ----
*/
public void setControllerObject(Class c) {
! clearCache();
if (c != null) {
setControllerObject(c.getName());
***************
*** 719,723 ****
*/
public void setOwnerController(String newController) {
! constructedParamString = null;
ownerObject = newController;
}
--- 743,747 ----
*/
public void setOwnerController(String newController) {
! clearCache();
ownerObject = newController;
}
***************
*** 729,733 ****
*/
public void setParams(Hashtable newParams) {
! constructedParamString = null;
params = new Hashtable(newParams);
}
--- 753,757 ----
*/
public void setParams(Hashtable newParams) {
! clearCache();
params = new Hashtable(newParams);
}
***************
*** 742,746 ****
*/
public void setReturnToSenderParms(ControllerRequest newReturnToSenderRequest) {
! constructedParamString = null;
String oneParamName = null;
Object oneParamValue = null;
--- 766,770 ----
*/
public void setReturnToSenderParms(ControllerRequest newReturnToSenderRequest) {
! clearCache();
String oneParamName = null;
Object oneParamValue = null;
***************
*** 930,934 ****
*
* @param resolveControllerReference should the controller be resolved to
! * a mapping or should it just be the request path with a controler equals
* parameter. True if you want the URL mapped to a .do mapping.
* @return java.lang.String
--- 954,958 ----
*
* @param resolveControllerReference should the controller be resolved to
! * a mapping, or should it just be the request path with a controller equals
* parameter. True if you want the URL mapped to a .do mapping.
* @return java.lang.String
***************
*** 1019,1023 ****
* This URL is optimized, so it includes a "controller" param only if
* the destination controller is different than the controller of the ControllerResponse (if
! * the response is known). For a guaranteed controller param,
*
* @return java.lang.String
--- 1043,1047 ----
* This URL is optimized, so it includes a "controller" param only if
* the destination controller is different than the controller of the ControllerResponse (if
! * the response is known).
*
* @return java.lang.String
***************
*** 1317,1319 ****
}
}
! } /* Transition */
\ No newline at end of file
--- 1341,1343 ----
}
}
! } /* Transition */
Index: ServletControllerResponse.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/ServletControllerResponse.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
More information about the cvs
mailing list