dev@javaserverfaces.java.net

Re: [Fwd: [REVIEW] Minor fix to Util.getScope()]

From: Roger Kitain <Roger.Kitain_at_Sun.COM>
Date: Tue, 10 Aug 2004 09:28:05 -0400

r = rogerk [contigent upon successful runs of api/ri/demo tests]

Ryan Lubke wrote:

>
> Slight amendment to the diff. Expression is unneeded.
>
>
>
> Section: Diffs
> -----------------------------
> Index: src/com/sun/faces/util/Util.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v
> retrieving revision 1.142
> diff -u -r1.142 Util.java
> --- src/com/sun/faces/util/Util.java 26 Jul 2004 21:12:44 -0000
> 1.142
> +++ src/com/sun/faces/util/Util.java 9 Aug 2004 20:48:04 -0000
> @@ -1348,24 +1348,13 @@
>
> //examine first segment and see if it is a scope
> String identifier = valueBinding;
> - String expression = null;
>
> if (segmentIndex > 0) {
> //get first segment designated by a "." or "["
> - identifier = valueBinding.substring(0, segmentIndex);
> -
> - //get second segment designated by a "." or "["
> - expression = valueBinding.substring(segmentIndex + 1);
> - segmentIndex = getFirstSegmentIndex(expression);
> -
> - if (segmentIndex > 0) {
> - expression = expression.substring(0, segmentIndex);
> - }
> + identifier = valueBinding.substring(0,
> segmentIndex); }
>
> - //check to see if the identifier is a named scope. If it is
> check
> - //for the expression in that scope. The expression is the
> - //second segment.
> + //check to see if the identifier is a named scope.
>
> FacesContext context = FacesContext.getCurrentInstance();
> ExternalContext ec = context.getExternalContext();
> @@ -1374,28 +1363,13 @@
> outString[0] = identifier;
> }
> if (identifier.equalsIgnoreCase(RIConstants.REQUEST_SCOPE)) {
> - if ((expression != null) &&
> - (ec.getRequestMap().get(expression) != null)) {
> - return RIConstants.REQUEST;
> - } else {
> - return null;
> - }
> + return RIConstants.REQUEST;
> }
> if (identifier.equalsIgnoreCase(RIConstants.SESSION_SCOPE)) {
> - if ((expression != null) &&
> - (Util.getSessionMap(context).get(expression) != null)) {
> - return RIConstants.SESSION;
> - } else {
> - return null;
> - }
> + return RIConstants.SESSION;
> }
> if (identifier.equalsIgnoreCase(RIConstants.APPLICATION_SCOPE)) {
> - if ((expression != null) &&
> - (ec.getApplicationMap().get(expression) != null)) {
> - return RIConstants.APPLICATION;
> - } else {
> - return null;
> - }
> + return RIConstants.APPLICATION;
> }
>
> // handle implicit objects
> Index: test/com/sun/faces/el/TestValueBindingImpl.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/el/TestValueBindingImpl.java,v
>
> retrieving revision 1.32
> diff -u -r1.32 TestValueBindingImpl.java
> --- test/com/sun/faces/el/TestValueBindingImpl.java 7 May 2004
> 13:53:25 -0000 1.32
> +++ test/com/sun/faces/el/TestValueBindingImpl.java 9 Aug 2004
> 20:48:07 -0000
> @@ -682,11 +682,7 @@
> property = null;
> assertNull(Util.getScope(property, null));
> property = "foo.sessionScope";
> - assertNull(Util.getScope(property, null));
> - property = "sessionScope";
> - assertNull(Util.getScope(property, null));
> - property = "sessionScope[";
> - assertNull(Util.getScope(property, null));
> + assertNull(Util.getScope(property, null));
> }
> -------- Original Message --------
> Subject: [REVIEW] Minor fix to Util.getScope()
> Date: Mon, 09 Aug 2004 16:09:09 -0400
> From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
> Reply-To: dev_at_javaserverfaces.dev.java.net
> To: dev_at_javaserverfaces.dev.java.net
>
>
>
> The recent scope change by Roger allowed the TCK to expose a
> problem in Util.getScope(). The test previously passed, but for
> the wrong reason.
>
> SECTION: Modified Files
> -------------------------------------
> M src/com/sun/faces/util/Util.java
> - Removed logic, that after validating a particular scope, would
> check for a non-null value when evaluating the expression.
> Null is a valid return. We're only concerned with the scope
> in this case.
>
> M test/com/sun/faces/el/TestValueBindingImpl.java
> - Test modification to reflect changes above.
>
>
> SECTION: Diffs
> -------------------------------------
> Index: src/com/sun/faces/util/Util.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v
> retrieving revision 1.142
> diff -u -r1.142 Util.java
> --- src/com/sun/faces/util/Util.java 26 Jul 2004 21:12:44 -0000
> 1.142
> +++ src/com/sun/faces/util/Util.java 9 Aug 2004 20:07:42 -0000
> @@ -1374,28 +1374,13 @@
> outString[0] = identifier;
> }
> if (identifier.equalsIgnoreCase(RIConstants.REQUEST_SCOPE)) {
> - if ((expression != null) &&
> - (ec.getRequestMap().get(expression) != null)) {
> - return RIConstants.REQUEST;
> - } else {
> - return null;
> - }
> + return RIConstants.REQUEST;
> }
> if (identifier.equalsIgnoreCase(RIConstants.SESSION_SCOPE)) {
> - if ((expression != null) &&
> - (Util.getSessionMap(context).get(expression) != null)) {
> - return RIConstants.SESSION;
> - } else {
> - return null;
> - }
> + return RIConstants.SESSION;
> }
> if (identifier.equalsIgnoreCase(RIConstants.APPLICATION_SCOPE)) {
> - if ((expression != null) &&
> - (ec.getApplicationMap().get(expression) != null)) {
> - return RIConstants.APPLICATION;
> - } else {
> - return null;
> - }
> + return RIConstants.APPLICATION;
> }
>
> // handle implicit objects
> Index: test/com/sun/faces/el/TestValueBindingImpl.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/el/TestValueBindingImpl.java,v
>
> retrieving revision 1.32
> diff -u -r1.32 TestValueBindingImpl.java
> --- test/com/sun/faces/el/TestValueBindingImpl.java 7 May 2004
> 13:53:25 -0000 1.32
> +++ test/com/sun/faces/el/TestValueBindingImpl.java 9 Aug 2004
> 20:07:45 -0000
> @@ -682,11 +682,7 @@
> property = null;
> assertNull(Util.getScope(property, null));
> property = "foo.sessionScope";
> - assertNull(Util.getScope(property, null));
> - property = "sessionScope";
> - assertNull(Util.getScope(property, null));
> - property = "sessionScope[";
> - assertNull(Util.getScope(property, null));
> + assertNull(Util.getScope(property, null));
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net