[ 
https://issues.apache.org/jira/browse/TOBAGO-802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770088#action_12770088
 ] 

Sven Bunge commented on TOBAGO-802:
-----------------------------------

The code
    new SelectItem("  ", null);
doesn't throw an exception.

I googled a bit and found the sourcecode of the used JSF-Library (Sun JSF 1.1)
The behavior of the Sun JSF1.1 implementation seems not like the provided 
JavaDoc:

The called construktor:
    /**
     * .........
     * @exception NullPointerException if <code>value</code>
     *  or <code>label</code> <code>null</code>
     */
    public SelectItem(Object value, String label) {
        this(value, label, null, false);
    }

The constructor with 4 parameters call the setValue() and the 
setLabel()-Methods to set the parameter (or to throw a NullpointerException). 
setValue do the check:
        if (value == null) {
            throw new NullPointerException();
        }

but setLabel:
    /**
     * <p>Set the label of this item, to be rendered visibly for the user.
     *
     * @param label The new label
     *
     * @exception NullPointerException if <code>label</code>
     *  is <code>null</code>
     */
    public void setLabel(String label) {
        this.label = label;
    }

So long it is not a bug in tobago.

> SelectItem-Name in selectOneChoice is not null-save
> ---------------------------------------------------
>
>                 Key: TOBAGO-802
>                 URL: https://issues.apache.org/jira/browse/TOBAGO-802
>             Project: MyFaces Tobago
>          Issue Type: Bug
>    Affects Versions: 1.0.23
>         Environment: Tobago 1.0.24-SNAPSHOT; java version "1.6.0_16", linux
>            Reporter: Sven Bunge
>            Assignee: Udo Schnurpfeil
>            Priority: Minor
>
> A javax.faces.model.SelectItem with an itemName 'null' will result in an 
> strange NPE. Everyone (like me ;-)) will guess that tobago handle it like an 
> empty string.
> Example:
>   public List<SelectItem> getItems() {
>     List<SelectItem> items = new ArrayList<SelectItem>();
>     for (int i = 0; i <a.size(); i++) {
>       items.add(new SelectItem(a.get(i), a.getName())); // a.getName is null
>     }
>     return items;
>   }
> will result in:
> 2009-10-19 11:13:43,342 TP-Processor3 ERROR - 
> org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/erm].[FacesServlet]:253
>  - Servlet.service() for servlet FacesServlet t
> hrew exception
> java.lang.NullPointerException
>         at 
> org.apache.myfaces.tobago.util.HtmlWriterUtil.writeText(HtmlWriterUtil.java:59)
>         at 
> org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.writeText(TobagoResponseWriterImpl.java:178)
>         at 
> org.apache.myfaces.tobago.webapp.TobagoResponseWriter.writeText(TobagoResponseWriter.java:171)
>         at 
> org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil.renderSelectItems(HtmlRendererUtil.java:641)
>         at 
> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.SelectOneChoiceRenderer.encodeEnd(SelectOneChoiceRenderer.java:97)
>         at 
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:740)
>         at 
> org.apache.myfaces.tobago.renderkit.RenderUtil.encode(RenderUtil.java:86)
>         at 
> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.GridLayoutRenderer.encodeChildrenOfComponent(GridLayoutRenderer.java:379)
>         at 
> org.apache.myfaces.tobago.component.UILayout.encodeChildrenOfComponent(UILayout.java:70)
>         at 
> org.apache.myfaces.tobago.component.UIGridLayout.encodeChildrenOfComponent(UIGridLayout.java:276)
>         at 
> org.apache.myfaces.tobago.component.UIPanelBase.encodeChildren(UIPanelBase.java:43)
>         at 
> org.apache.myfaces.tobago.renderkit.RenderUtil.encode(RenderUtil.java:79)
>         at 
> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.GridLayoutRenderer.encodeChildrenOfComponent(GridLayoutRenderer.java:379)
>         at 
> org.apache.myfaces.tobago.component.UILayout.encodeChildrenOfComponent(UILayout.java:70)
>         at 
> org.apache.myfaces.tobago.component.UIGridLayout.encodeChildrenOfComponent(UIGridLayout.java:276)
>         at 
> org.apache.myfaces.tobago.component.UIPanelBase.encodeChildren(UIPanelBase.java:43)
>         at 
> org.apache.myfaces.tobago.renderkit.RenderUtil.encode(RenderUtil.java:79)
>         at 
> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.GridLayoutRenderer.encodeChildrenOfComponent(GridLayoutRenderer.java:379)
>         at 
> org.apache.myfaces.tobago.component.UILayout.encodeChildrenOfComponent(UILayout.java:70)
>         at 
> org.apache.myfaces.tobago.component.UIGridLayout.encodeChildrenOfComponent(UIGridLayout.java:276)
>         at 
> org.apache.myfaces.tobago.component.UIPanelBase.encodeChildren(UIPanelBase.java:43)
>         at 
> org.apache.myfaces.tobago.renderkit.RenderUtil.encode(RenderUtil.java:79)
>         at 
> org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.GridLayoutRenderer.encodeChildrenOfComponent(GridLayoutRenderer.java:379)
>         at 
> org.apache.myfaces.tobago.component.UILayout.encodeChildrenOfComponent(UILayout.java:70)
>         at 
> org.apache.myfaces.tobago.component.UIGridLayout.encodeChildrenOfComponent(UIGridLayout.java:276)
>         at 
> org.apache.myfaces.tobago.renderkit.RenderUtil.encodeChildren(RenderUtil.java:58)

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

Reply via email to