You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jörg Rothbarth (JIRA)" <de...@myfaces.apache.org> on 2008/07/14 13:01:32 UTC

[jira] Created: (MYFACES-1897) escape value of a selectItem is never evaluated

escape value of a selectItem is never evaluated
-----------------------------------------------

                 Key: MYFACES-1897
                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-252
    Affects Versions: 1.2.3
            Reporter: Jörg Rothbarth


The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
The selectItem Component has a escape member, but the member is never used. 

To fix the problem i've done this:

HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :

// label element after the input
boolean componentDisabled = isDisabled(facesContext, selectOne);
boolean disabled = (componentDisabled || itemDisabled);
boolean escape = selectItem.isEscape();

HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
                selectItem.getLabel(), disabled,escape);

HtmlRendererUtils.renderLabel() Line ~1352:

public static void renderLabel(ResponseWriter writer, UIComponent    
    component, String forClientId,String labelValue, boolean    
                disabled) throws IOException {
renderLabel(writer, component, forClientId, labelValue, disabled, true);
}


/**
 * Renders a label HTML element
 */
public static void renderLabel(ResponseWriter writer, UIComponent
            component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {

...

if ((labelValue != null) && (labelValue.length() > 0)) {
    writer.write(HTML.NBSP_ENTITY);
    if (escape) {
        writer.writeText(labelValue, null);
    } else {
        writer.write(labelValue);
    }
}
... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Paul Rivera (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619915#action_12619915 ] 

Paul Rivera commented on MYFACES-1897:
--------------------------------------

Hi!

I've attached myfaces-1897.patch that fixes your problem.  Here are the details of the fix:

I) I've modified HtmlRenderUtils.renderLabel to accept the SelectItem parameter.  This way, we are passing less parameters and we can get both labelValue and escape values plus any other SelectItem attribute we might need to use inside renderLabel() in the future.
     public static void renderLabel(ResponseWriter writer,
                                    UIComponent component,
                                    String forClientId,
-                                   String labelValue,
+                                   SelectItem item,
                                    boolean disabled) throws IOException

I also modified the part where escape gets evaluated (almost identical to the fix suggested in the first post):
-            if ((labelValue != null) && (labelValue.length() > 0))
+            if ((item.getLabel() != null) && (item.getLabel().length() > 0))
             {
                 writer.write(HTML.NBSP_ENTITY);
-                writer.writeText(labelValue, null);
+                                
+                if(item.isEscape())
+                {
+                    writer.writeText(item.getLabel(), null);
+                }
+                else
+                {
+                    writer.write(item.getLabel());
+                }
             }

Now, this fix is enough if you are creating your SelectItem objects with its constructor. I.e.:
new SelectItem("1","<b>Escaped</b>","choose_one",false,true)

But if you make it using its tag:
<f:selectItem itemLabel="<b>Escaped</b>" itemValue="choose_one" escape="true" />

The tag above will be treated as if escape="false".  There is a problem with SelectItemTagBase.setProperties().  SelectItemTagBase sets the property of your UISelectItem using UISelectItem.setEscape().  But UISelectItem doesn't have setEscape().  It has setItemEscaped().  Note that UISelectItem.getItemEscaped() returns false by default.  Since setItemEscaped() is never called, it will always return false.

Root cause of this is because in your SelectItemTagBase.setProperties(), this gets called:
setBooleanProperty(component, JSFAttr.ESCAPE_ATTR, _escape, Boolean.TRUE);

The value of JSFAttr.ESCAPE_ATTR is 'escape'.  If you dig deep into this method, you will notice that it will look for UISelectItem.setEscape() in _ComponentAttributes.put().  Again, UISelectItem does not have a setEscape(), it uses setItemEscaped(). In _ComponentAttributes.put() L299, propertyDescriptor will be null and the value gets added to _attributes instead of calling setComponentProperty().

To fix this, either:
A)  change JSFAttr.ESCAPE_ATTR from 'escape' to 'itemEscaped'
    CONS: ESCAPE_ATTR is being used by a lot of other classes which expect the value 'escape'.
B)  change UISelectItem's method from isItemEscaped()/setItemEscaped() to isEscape()/setEscape()
    CONS: Breaks API for JSF 1.2.
C)  Add a new JSFAttr.ITEM_ESCAPED_ATTR with the value 'itemEscaped'

Option C was for me the most logical one.  So I've updated SelectItemTagBase.setProperties():
-        setBooleanProperty(component, JSFAttr.ESCAPE_ATTR, _escape, Boolean.TRUE);
+        setBooleanProperty(component, JSFAttr.ITEM_ESCAPED_ATTR, _escape, Boolean.TRUE);

II) I've updated both HtmlCheckboxRendererBase and HtmlRadioRendererBase that makes calls to HtmlRenderUtils.renderLabel().
III) To fix selectOneMenu, selectManyMenu, selectOneListbox, and selectManyListbox, I've modified 
HtmlRendererUtils.renderSelectOptions():
-                boolean escape;
-                if (component instanceof EscapeCapable)
+                if(selectItem.isEscape())
                 {
-                    escape = ((EscapeCapable)component).isEscape();
-                }
-                else
-                {
-                    escape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR,
-                                                               true); //default is to escape
-                }
-
-                if (escape || selectItem.isEscape())
-                {
                     writer.writeText(selectItem.getLabel(), null);
                 } else
                 {
The original code checks for isEscape() in the component parameter which is can be an HtmlSelectOneMenu, HtmlSelectOneListbox, HtmlSelectManyMenu, HtmlSelectManyListbox -> all of which don't have an 'escape' attribute defined in the TLD.  In the JSF 1.2 RI, these components don't have the escape attribute as well.  

So I removed the checking for isEscape() from the component and focused on the isEscape() of the SelectItem instead.

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: myfaces-1897.patch, SelectItemEscapeBean.java, selectOneManyEscape.jsp
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620679#action_12620679 ] 

Leonardo Uribe commented on MYFACES-1897:
-----------------------------------------

Yes, could you open a new issue on tomahawk, please?. We have also to check the behavior on both tomahawk core and core12, because the renderer classes are a little bit different.

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: myfaces-1897-2.patch, SelectItemEscapeBean.java, selectOneManyEscape.jsp, tomahawk12-HtmlCheckboxRenderer.patch
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619180#action_12619180 ] 

Leonardo Uribe commented on MYFACES-1897:
-----------------------------------------

I have added the files necessary for test this feature.

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: SelectItemEscapeBean.java, selectOneManyEscape.jsp
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621596#action_12621596 ] 

Leonardo Uribe commented on MYFACES-1897:
-----------------------------------------

Hi

This issue has been more difficult that it seems at start.

So UISelectItem has a jsp property name as "escape", but on the component class is "itemEscape". In that case the patch is necessary for now (I also committed the correction on the annotation, but in the future this part should be generated).

I'll commit a modified solution of your patch, because there still some objections:

1. javax.faces.model.SelectItem was a new addition on 1.2 (escape property). The documentation says that in any constructor with params without escape defined, this property should be initialized by default as true. It has sense, but right now myfaces core is doing the opposite, so this should be corrected. The issue was never noted because there exists a code like this:

                if (component instanceof EscapeCapable)
                {
                    escape = ((EscapeCapable)component).isEscape();
                }
                else
                {
                    escape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR,
                                                               true); //default is to escape
                }

The else part of the if makes escape everything by default. 

2. There are tomahawk components that use the method:

    public static void renderSelectOptions(FacesContext context,
                                           UIComponent component, Converter converter, Set lookupSet,
                                           List selectItemList) throws IOException {

This method contains the previous discussed code. All tomahawk components that use this method implements EscapeCapable interface (and has an escape property for the whole component by default true). But the changes must be done remaining compatibility with this property. Just do this:

                    escape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR,
                                                               false);

does not solve the problem, because if escape="false" for some tomahawk component, by default on SelectItem is true, so the result (do not escape anything) is not get.

In conclusion the solution should be something like this:

                boolean escape;
                if (component instanceof EscapeCapable)
                {
                    escape = ((EscapeCapable)component).isEscape();
                    
                    // Preserve tomahawk semantic. If escape=false
                    // all items should be non escaped. If escape
                    // is true check if selectItem.isEscape() is
                    // true and do it.
                    // This is done for remain compatibility.
                    if (escape && selectItem.isEscape())
                    {
                        writer.writeText(selectItem.getLabel(), null);
                    } else
                    {
                        writer.write(selectItem.getLabel());
                    }
                }
                else
                {
                    escape = RendererUtils.getBooleanAttribute(component, JSFAttr.ESCAPE_ATTR,
                                                               false);
                    //default is to escape
                    //In JSF 1.2, when a SelectItem is created by default 
                    //selectItem.isEscape() returns true (this property
                    //is not available on JSF 1.1).
                    //so, if we found a escape property on the component
                    //set to true, escape every item, but if not
                    //check if isEscape() = true first.
                    if (escape || selectItem.isEscape())
                    {
                        writer.writeText(selectItem.getLabel(), null);
                    } else
                    {
                        writer.write(selectItem.getLabel());
                    }
                }

I'll commit this solution and close this issue right now. But I cannot commit tomahawk patch (it is correct but It is necessary to  create another issue on tomahawk project with a reference to this issue). Please create it and I'll commit the patch.

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: myfaces-1897-part1.patch, myfaces-1897-part2.patch, SelectItemEscapeBean.java, selectOneManyEscape-simple.jsp, selectOneManyEscape.jsp, tomahawk12-HtmlCheckboxRenderer.patch, tomahawk12-HtmlRadioRenderer.patch
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620117#action_12620117 ] 

Leonardo Uribe commented on MYFACES-1897:
-----------------------------------------


The shared project 3.0.x is used for tomahawk12 and myfaces core12. So one change here affects in the other side and viceversa. At first look, I see that maybe the changes introduce bugs on some related components  (t:selectXXX). Specially this part:

- boolean escape;
- if (component instanceof EscapeCapable)
+ if(selectItem.isEscape())
                 {
- escape = ((EscapeCapable)component).isEscape();
- }
- else 

Could you test this if I'm wrong?

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: myfaces-1897.patch, SelectItemEscapeBean.java, selectOneManyEscape.jsp
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Paul Rivera (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12622155#action_12622155 ] 

Paul Rivera commented on MYFACES-1897:
--------------------------------------

I've created TOMAHAWK-1314 for the tomahawk patch.

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>             Fix For: 1.2.4-SNAPSHOT
>
>         Attachments: myfaces-1897-part1.patch, myfaces-1897-part2.patch, SelectItemEscapeBean.java, selectOneManyEscape-simple.jsp, selectOneManyEscape.jsp, tomahawk12-HtmlCheckboxRenderer.patch, tomahawk12-HtmlRadioRenderer.patch
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Updated: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Simon-Pierre Béliveau (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simon-Pierre Béliveau updated MYFACES-1897:
-------------------------------------------

    Status: Patch Available  (was: Open)

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: myfaces-1897.patch, SelectItemEscapeBean.java, selectOneManyEscape.jsp
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619179#action_12619179 ] 

Leonardo Uribe commented on MYFACES-1897:
-----------------------------------------

After doing some tests, the problem is present on all h:selectXXX components, so a solution for all six components is needed

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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


[jira] Commented: (MYFACES-1897) escape value of a selectItem is never evaluated

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621022#action_12621022 ] 

Leonardo Uribe commented on MYFACES-1897:
-----------------------------------------

Hi Paul

I have some suggestions about the patch provided (myfaces-1897-2.patch):

1. Look jsf tlddoc documentation for 1.2_MR1

http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/tlddocs/

 It is not necessary to modify JSFAttr and SelectItemTagBase, since the code is correct.

2. There was a recent change on tomahawk core 1.2 class HtmlRadioRenderer that calls renderLabel method, so a new patch including the change on this class is needed. Personally I prefer let the old method and include a new one with escape capability, rather than remove it, (if it is necessary put the old one as deprecated).

3. Run the test I provided with jsf ri 1.2_09 (it has the correct behavior for all components). I can see the solution but only for two components, not all six.

> escape value of a selectItem is never evaluated
> -----------------------------------------------
>
>                 Key: MYFACES-1897
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1897
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.3
>            Reporter: Jörg Rothbarth
>            Assignee: Leonardo Uribe
>         Attachments: myfaces-1897-2.patch, SelectItemEscapeBean.java, selectOneManyEscape.jsp, tomahawk12-HtmlCheckboxRenderer.patch
>
>
> The escape Attribute of a selectItem Component is not evaluated inside a selectOneRadio component.
> The selectItem Component has a escape member, but the member is never used. 
> To fix the problem i've done this:
> HtmlRadioRendererBase.renderGroupOrItemRadio() Line ~199 :
> // label element after the input
> boolean componentDisabled = isDisabled(facesContext, selectOne);
> boolean disabled = (componentDisabled || itemDisabled);
> boolean escape = selectItem.isEscape();
> HtmlRendererUtils.renderLabel(writer, selectOne, itemId,
>                 selectItem.getLabel(), disabled,escape);
> HtmlRendererUtils.renderLabel() Line ~1352:
> public static void renderLabel(ResponseWriter writer, UIComponent    
>     component, String forClientId,String labelValue, boolean    
>                 disabled) throws IOException {
> renderLabel(writer, component, forClientId, labelValue, disabled, true);
> }
> /**
>  * Renders a label HTML element
>  */
> public static void renderLabel(ResponseWriter writer, UIComponent
>             component, String forClientId,String labelValue,         boolean disabled, boolean escape) throws IOException {
> ...
> if ((labelValue != null) && (labelValue.length() > 0)) {
>     writer.write(HTML.NBSP_ENTITY);
>     if (escape) {
>         writer.writeText(labelValue, null);
>     } else {
>         writer.write(labelValue);
>     }
> }
> ... 

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