[richfaces-issues] [JBoss JIRA] Commented: (RF-6596) InplaceSelect with Enum => Cast exception

Leonid Sokolin (JIRA) jira-events at lists.jboss.org
Tue Mar 9 17:32:58 EST 2010


    [ https://jira.jboss.org/jira/browse/RF-6596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12519059#action_12519059 ] 

Leonid Sokolin commented on RF-6596:
------------------------------------

I have similar problem using a combo box. I want to populate combo box with list of values selected in shuttleList.

I have the following shuttleList:

<rich:listShuttle id="selectTimePeriods" sourceValue="#{qtBeanParam.allTrailingPeriods}"
		            targetValue="#{qtBeanParam.selectedTrailingPeriods}" var="itemTime" 
		            listsHeight="150"
		            sourceListWidth="150" sourceCaptionLabel="Available Trailing Periods"
		            targetListWidth="150" targetCaptionLabel="Selected Trailing Periods"
		            targetRequired="true" requiredMessage="Periods should be selected."
		            copyAllControlLabel="" copyControlLabel="" removeAllControlLabel="" removeControlLabel=""
		            upControlLabel="" topControlLabel="" downControlLabel="" bottomControlLabel=""
		            >
		            <rich:column width="120">
		                <h:outputText value="#{itemTime.display}"></h:outputText>
		            </rich:column>
		            <a4j:support event="onlistchanged" reRender="sortPeriod,sortPeriodList" ajaxSingle="true"/>
		        </rich:listShuttle>

and put the following in dependent combo box:

<rich:comboBox id="sortPeriod" width="100" value="#{qtBeanParam.sortPeriod}" >
<f:selectItems id="sortPeriodList" value="#{qtBeanParam.selectedTrailingPeriods}" />
</rich:comboBox>

Problem is that values selected in the shuttleList are enums:

public enum TrailingPeriods {
	MostRecentMonth(1,"MRM"), MostRecentQuarter(3,"MRQ"), SixMonths(6, "6 M"), YearToDate(-1, "YTD"), OneYear(12, "1 Yr"), 
	TwoYear(2*12, "2 Yrs"), ThreeYear(3*12, "3 Yrs"), FourYear(4*12, "4 Yrs"), FiveYear(5*12, "5 Yrs"), 
	SixYear(6*12, "6 Yrs"), SevenYear(7*12, "7 Yrs"), EightYear(8*12, "8 Yrs"), NineYear(9*12, "9 Yrs"), 
	TenYear(10*12, "10 Yrs"), SinceInception(-10, "Since Inception");
...

And it throws cast exception when shuttleList is changed:

17:22:48,656 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
java.lang.ClassCastException: com.nb.pi.processor.beans.TrailingPeriods
	at org.richfaces.renderkit.ComboBoxBaseRenderer.encodeItems(ComboBoxBaseRenderer.java:96)
	at org.richfaces.renderkit.html.ComboBoxRenderer.doEncodeEnd(ComboBoxRenderer.java:558)
	at org.richfaces.renderkit.html.ComboBoxRenderer.doEncodeEnd(ComboBoxRenderer.java:587)
	at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
...

Does it mean that I coudn;t use enums here?


> InplaceSelect with Enum => Cast exception
> -----------------------------------------
>
>                 Key: RF-6596
>                 URL: https://jira.jboss.org/jira/browse/RF-6596
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.3.0
>            Reporter: julien colin
>            Assignee: Nick Belaevski
>             Fix For: 3.3.1
>
>
> I've an Enum "Report" with these values "ALL,DELIVERED,NONE,UNDEFINED"
> This code with 3.2.2 it works.
> Code:
> <rich:inplaceSelect value="#{account.deliveryReport}"
> editEvent="onclick" selectOnEdit="true"
> defaultLabel="click to edit">
> <s:enumItem enumValue="ALL" itemLabel="ALL" />
> <s:enumItem enumValue="DELIVERED" itemLabel="DELIVERED" />
> <s:enumItem enumValue="NONE" itemLabel="NONE" />
> <s:enumItem enumValue="UNDEFINED" itemLabel="UNDEFINED" />
> <s:convertEnum />
> <a4j:support event="onviewactivated" eventsQueue="customer"
> action="#{entityManager.flush}" />
> </rich:inplaceSelect>	
> with 3.3.1 i have a cast exception:
> java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Enum
>         at org.jboss.seam.ui.converter.EnumConverter.getAsString(EnumConverter.java:56)
>         at org.ajax4jsf.util.InputUtils.getConvertedStringValue(InputUtils.java:114)
>         at org.richfaces.renderkit.ComboBoxBaseRenderer.getConvertedStringValue(ComboBoxBaseRenderer
> .java:131)
>         at org.richfaces.renderkit.ComboBoxBaseRenderer.encodeSuggestion(ComboBoxBaseRenderer.java:1
> 38)
>         at org.richfaces.renderkit.InplaceSelectBaseRenderer.encodeItems(InplaceSelectBaseRenderer.j
> ava:101)
>         at org.richfaces.renderkit.html.InplaceSelectRenderer.doEncodeEnd(InplaceSelectRenderer.java
> :612)
>         at org.richfaces.renderkit.html.InplaceSelectRenderer.doEncodeEnd(InplaceSelectRenderer.java
> :645)
>         at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
>         at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
> 	

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

        


More information about the richfaces-issues mailing list