You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Steve Peterson (JIRA)" <de...@myfaces.apache.org> on 2005/12/30 21:48:02 UTC

[jira] Created: (MYFACES-990) Unhelpful stack trace when tag value binding returns wrong type.

Unhelpful stack trace when tag value binding returns wrong type.
----------------------------------------------------------------

         Key: MYFACES-990
         URL: http://issues.apache.org/jira/browse/MYFACES-990
     Project: MyFaces
        Type: Improvement
  Components: Implementation  
    Versions: 1.1.1    
    Reporter: Steve Peterson
    Priority: Minor


In the implementation of each UIComponent, the canonical logic for retrieving a non-String property is to cast the result
of the valueBinding.getValue() method to the expected type.

    public boolean isItemDisabled()
    {
        if (_itemDisabled != null) return _itemDisabled.booleanValue();
        ValueBinding vb = getValueBinding("itemDisabled");
        Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
        return v != null ? v.booleanValue() : DEFAULT_ITEMDISABLED;
    }

Yields an obscure stack trace that doesn't yield the ID of the component or the property that is being referenced:

ERROR 14:45:28 [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: java.lang.String
        at javax.faces.component.html.HtmlInputText.isDisabled(HtmlInputText.java:117)
        at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.isDisabled(HtmlTextRendererBase.java:157)
        at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.isDisabled(HtmlTextRenderer.java:45)
        at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:144)
        at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:50)
        at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.renderNormal(HtmlTextRenderer.java:72)
        at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.encodeEnd(HtmlTextRenderer.java:58)



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MYFACES-990) Unhelpful stack trace when tag value binding returns wrong type.

Posted by "Steve Peterson (JIRA)" <de...@myfaces.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-990?page=all ]

Steve Peterson updated MYFACES-990:
-----------------------------------

    Attachment: typed-value-binding.patch

This patch modifies every standard component implementation to change the logic behind typed references to the result of evaluating value bindings.  The evaluation result is tested to determine whether it matches the expected type, and, if not, an EvaluationException is thrown giving the component's ID, the binding, the expected type, and the actual returned type.  The most common changes were Boolean, Number, and Converter results.  Value bindings that returned Object or String were not modified.

These changes rely on a new helper method _ComponentUtils.getTypedValue() in both javax.faces.Component and javax.faces.component.Html to do the work of testing the resulting type and throw the exception.  Note that this code is identical in both packages, which seems to be the pattern for this helper class.

> Unhelpful stack trace when tag value binding returns wrong type.
> ----------------------------------------------------------------
>
>          Key: MYFACES-990
>          URL: http://issues.apache.org/jira/browse/MYFACES-990
>      Project: MyFaces
>         Type: Improvement
>   Components: Implementation
>     Versions: 1.1.1
>     Reporter: Steve Peterson
>     Priority: Minor
>  Attachments: typed-value-binding.patch
>
> In the implementation of each UIComponent, the canonical logic for retrieving a non-String property is to cast the result
> of the valueBinding.getValue() method to the expected type.
>     public boolean isItemDisabled()
>     {
>         if (_itemDisabled != null) return _itemDisabled.booleanValue();
>         ValueBinding vb = getValueBinding("itemDisabled");
>         Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
>         return v != null ? v.booleanValue() : DEFAULT_ITEMDISABLED;
>     }
> Yields an obscure stack trace that doesn't yield the ID of the component or the property that is being referenced:
> ERROR 14:45:28 [[jsp]] Servlet.service() for servlet jsp threw exception
> java.lang.ClassCastException: java.lang.String
>         at javax.faces.component.html.HtmlInputText.isDisabled(HtmlInputText.java:117)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.isDisabled(HtmlTextRendererBase.java:157)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.isDisabled(HtmlTextRenderer.java:45)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:144)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:50)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.renderNormal(HtmlTextRenderer.java:72)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.encodeEnd(HtmlTextRenderer.java:58)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MYFACES-990) Unhelpful stack trace when tag value binding returns wrong type.

Posted by "Martin Marinschek (JIRA)" <de...@myfaces.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-990?page=all ]

Martin Marinschek updated MYFACES-990:
--------------------------------------

    Status: Patch Available  (was: Open)

> Unhelpful stack trace when tag value binding returns wrong type.
> ----------------------------------------------------------------
>
>                 Key: MYFACES-990
>                 URL: http://issues.apache.org/jira/browse/MYFACES-990
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 1.1.1
>            Reporter: Steve Peterson
>            Priority: Minor
>         Attachments: typed-value-binding.patch
>
>
> In the implementation of each UIComponent, the canonical logic for retrieving a non-String property is to cast the result
> of the valueBinding.getValue() method to the expected type.
>     public boolean isItemDisabled()
>     {
>         if (_itemDisabled != null) return _itemDisabled.booleanValue();
>         ValueBinding vb = getValueBinding("itemDisabled");
>         Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
>         return v != null ? v.booleanValue() : DEFAULT_ITEMDISABLED;
>     }
> Yields an obscure stack trace that doesn't yield the ID of the component or the property that is being referenced:
> ERROR 14:45:28 [[jsp]] Servlet.service() for servlet jsp threw exception
> java.lang.ClassCastException: java.lang.String
>         at javax.faces.component.html.HtmlInputText.isDisabled(HtmlInputText.java:117)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.isDisabled(HtmlTextRendererBase.java:157)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.isDisabled(HtmlTextRenderer.java:45)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:144)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:50)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.renderNormal(HtmlTextRenderer.java:72)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.encodeEnd(HtmlTextRenderer.java:58)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MYFACES-990) Unhelpful stack trace when tag value binding returns wrong type.

Posted by "Martin Marinschek (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531057 ] 

Martin Marinschek commented on MYFACES-990:
-------------------------------------------

This should be done in the component-generator - which is about to be reactived for tomahawk 1.2 ;)

regards,

Martin

> Unhelpful stack trace when tag value binding returns wrong type.
> ----------------------------------------------------------------
>
>                 Key: MYFACES-990
>                 URL: https://issues.apache.org/jira/browse/MYFACES-990
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 1.1.1
>            Reporter: Steve Peterson
>            Assignee: Martin Marinschek
>            Priority: Minor
>         Attachments: typed-value-binding.patch
>
>
> In the implementation of each UIComponent, the canonical logic for retrieving a non-String property is to cast the result
> of the valueBinding.getValue() method to the expected type.
>     public boolean isItemDisabled()
>     {
>         if (_itemDisabled != null) return _itemDisabled.booleanValue();
>         ValueBinding vb = getValueBinding("itemDisabled");
>         Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
>         return v != null ? v.booleanValue() : DEFAULT_ITEMDISABLED;
>     }
> Yields an obscure stack trace that doesn't yield the ID of the component or the property that is being referenced:
> ERROR 14:45:28 [[jsp]] Servlet.service() for servlet jsp threw exception
> java.lang.ClassCastException: java.lang.String
>         at javax.faces.component.html.HtmlInputText.isDisabled(HtmlInputText.java:117)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.isDisabled(HtmlTextRendererBase.java:157)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.isDisabled(HtmlTextRenderer.java:45)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:144)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:50)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.renderNormal(HtmlTextRenderer.java:72)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.encodeEnd(HtmlTextRenderer.java:58)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-990) Unhelpful stack trace when tag value binding returns wrong type.

Posted by "Steve Peterson (JIRA)" <de...@myfaces.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-990?page=comments#action_12361446 ] 

Steve Peterson commented on MYFACES-990:
----------------------------------------

The new message looks like this:

ERROR 14:57:45 [[jsp]] Servlet.service() for servlet jsp threw exception
javax.faces.el.EvaluationException: Evaluating disabled for fixedBarcodeNumberLength; expected type java.lang.Boolean but expression evaluated to java.lang.String
        at javax.faces.component.html._ComponentUtils.getTypedValue(_ComponentUtils.java:67)
        at javax.faces.component.html.HtmlInputText.isDisabled(HtmlInputText.java:116)
        at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.isDisabled(HtmlTextRendererBase.java:157)
        at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.isDisabled(HtmlTextRenderer.java:45)
        at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:144)

> Unhelpful stack trace when tag value binding returns wrong type.
> ----------------------------------------------------------------
>
>          Key: MYFACES-990
>          URL: http://issues.apache.org/jira/browse/MYFACES-990
>      Project: MyFaces
>         Type: Improvement
>   Components: Implementation
>     Versions: 1.1.1
>     Reporter: Steve Peterson
>     Priority: Minor
>  Attachments: typed-value-binding.patch
>
> In the implementation of each UIComponent, the canonical logic for retrieving a non-String property is to cast the result
> of the valueBinding.getValue() method to the expected type.
>     public boolean isItemDisabled()
>     {
>         if (_itemDisabled != null) return _itemDisabled.booleanValue();
>         ValueBinding vb = getValueBinding("itemDisabled");
>         Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
>         return v != null ? v.booleanValue() : DEFAULT_ITEMDISABLED;
>     }
> Yields an obscure stack trace that doesn't yield the ID of the component or the property that is being referenced:
> ERROR 14:45:28 [[jsp]] Servlet.service() for servlet jsp threw exception
> java.lang.ClassCastException: java.lang.String
>         at javax.faces.component.html.HtmlInputText.isDisabled(HtmlInputText.java:117)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.isDisabled(HtmlTextRendererBase.java:157)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.isDisabled(HtmlTextRenderer.java:45)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:144)
>         at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:50)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.renderNormal(HtmlTextRenderer.java:72)
>         at org.apache.myfaces.renderkit.html.ext.HtmlTextRenderer.encodeEnd(HtmlTextRenderer.java:58)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira