1 2 Previous Next 16 Replies Latest reply: Nov 13, 2012 1:20 AM by user404 Go to original post RSS
      • 15. Re: Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
        Timo Hahn
        I don't know what you do in your code, so I made a small test case:
        on the page:
                            <af:panelGroupLayout id="pgl1" layout="vertical">
                                <af:selectOneListbox label="Select"
                                                     value="#{pageFlowScope.SOCToggleBean.selValueSOC}"
                                                     id="sol1" autoSubmit="true">
                                    <af:selectItem label="Private" value="PRIV"
                                                   id="si1"/>
                                    <af:selectItem label="Goverment" value="GOV"
                                                   id="si2"/>
                                </af:selectOneListbox>
                                <af:panelGroupLayout id="pgl2" layout="horizontal">
                                    <af:panelLabelAndMessage label="Reg. Number"
                                                             id="plam1" for="it1"
                                                             partialTriggers="sol1"
                                                             showRequired="#{pageFlowScope.SOCToggleBean.selValueSOC ne 'GOV'}"/>
                                    <af:inputText label="Label 1" id="it1" simple="true"
                                                  validator="#{pageFlowScope.SOCToggleBean.it1_validator}" disabled="#{pageFlowScope.SOCToggleBean.selValueSOC eq 'GOV'}"
                                                  partialTriggers="sol1"/>
                                </af:panelGroupLayout>
                                <af:commandButton text="commandButton 1" id="cb1"
                                                  action="#{pageFlowScope.SOCToggleBean.cb1_action}"/>
                            </af:panelGroupLayout>
        and the bean SOCToggleBean
        package de.hahn.blog.xxyyzz.view.beans;
        
        import javax.faces.component.UIComponent;
        import javax.faces.context.FacesContext;
        
        public class SOCToggleBean {
            private String mSelValueSOC;
            
            public SOCToggleBean() {
            }
        
            public void setSelValueSOC(String mSelValueSOC) {
                this.mSelValueSOC = mSelValueSOC;
            }
        
            public String getSelValueSOC() {
                return mSelValueSOC;
            }
        
            public String cb1_action() {
                // Add event code here...
                return null;
            }
        }
        This code works for me. Please study the code and adopt it to your use case.

        Timo
        • 16. Re: Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
          user404
          Try to get rid of the
          immediate="true"'
          1 2 Previous Next