The following is an abbreviated (My stacktrace is really long) version
of my stacktrace:
java.lang.ClassCastException: com.oim.faces.custom.tabbedpane.UITabLabel
at
org.apache.myfaces.renderkit.html.HtmlLinkRendererBase.renderJavaScriptAnchorStart(HtmlLinkRendererBase.java:323)
at
org.apache.myfaces.renderkit.html.HtmlLinkRendererBase.renderCommandLinkStart(HtmlLinkRendererBase.java:215)
at org.apache.myfaces.renderkit.html.HtmlLinkRendererBase.encodeBegin
(HtmlLinkRendererBase.java:146)
at javax.faces.component.UIComponentBase.encodeBegin
(UIComponentBase.java:317)
at com.oim.faces.custom.tabbedpane.TabbedPaneRenderer.encodeRecursive
(TabbedPaneRenderer.java:406)
As you can see from the above, what triggers the exception is when I
call encodeRecursive in my renderer, which calls encodeBegin() method on
my component (UITabLabel). See previous post for implementation details.
_Curtney
On Thu, 2005-07-28 at 10:25 +0200, Martin Marinschek wrote:
> Find out which classes are involved in the failed casting and then get
> back to us.
>
> regards,
>
> Martin
>
> On 7/28/05, Curtney Jacobs <[EMAIL PROTECTED]> wrote:
> Greetings!
>
> I have copied a custom component from "JavaServer Faces" by
> O'Reilly to
> use in my myfaces application and I am getting
> ClassCastException
> whenever I call "component.encodeBegin(context)": The
> following code is
> what throws the ClassCastException:
>
> Calling code:
>
> UITabLabel tabLabel = (UITabLabel)child.getFacet("label");
> encodeRecursive(context, tabLabel);
>
> Called Method implementation:
>
> private void encodeRecursive (FacesContext context,
> UIComponent
> component) throws IOException {
> if (!component.isRendered()) {
> return;
> }
> //throws ClassCastException
> component.encodeBegin (context);
>
> if (component.getRendersChildren()) {
> component.encodeChildren(context);
> } else {
> Iterator it = component.getChildren
> ().iterator();
> while (it.hasNext()) {
> UIComponent child =
> (UIComponent)it.next();
> encodeRecursive(context,
> child);
> }
> }
> component.encodeEnd(context);
> }
>
>
> The following is the custom component from the Book:
>
> public class UITabLabel extends UICommand {
>
> public static final String COMPONENT_TYPE =
> "com.oim.faces.TabLabel";
> public static final String COMPONENT_FAMILY =
> "javax.faces.Command";
>
> public UITabLabel () {
> super();
> setRendererType ("javax.faces.Link");
> }
>
> public String getFamily () {
> return COMPONENT_FAMILY;
> }
>
> public void broadcast (FacesEvent event) {
> if (event instanceof ActionEvent) {
> processAction((ActionEvent)event);
> }
> }
>
>
> private void processAction (ActionEvent event) {
> UIComponent panelTab = getParent();
> UIComponent panelTabbedPane =
> panelTab.getParent();
> Iterator it = panelTabbedPane.getChildren
> ().iterator();
> while (it.hasNext()) {
> UIComponent panel =
> (UIComponent)it.next();
> if (panel.equals(panelTab)) {
> panel.setRendered(true);
> } else {
> panel.setRendered(false);
> }
> }
> }
>
> public MethodBinding getAction () {
> return null;
> }
>
> public void setAction (MethodBinding action) {
> throw new UnsupportedOperationException();
> }
>
> public MethodBinding getActionListener () {
> return null;
> }
>
> public void addActionListener (ActionListener
> listener) {
> throw new UnsupportedOperationException();
> }
>
> public ActionListener[] getActionListeners () {
> return new ActionListener[0];
> }
>
> public void removeActionListener (ActionListener
> listener) {
> throw new UnsupportedOperationException ();
> }
>
> }
>
> Any Ideas?
>
> Curtney
>
>