Greetings Eric,
what you have listed would just recursively call my encodeBegin() method
in my renderer class, since this is where I am calling encodeRecursive
() method in the first place. However, I did tried it and got errors, as
expected. From what I have read and understood the UITabLabel suppose to
use its own renderer to display itself.
Has anyone else ran into this problem before?
Curtney
On Thu, 2005-07-28 at 08:22 -0500, Eric Kelm wrote:
> I had problems when I tried to use this example as well. Look at the method
> signatures. If I remember correctly the functions are not being called
> correctly. E.G.
>
> Method signature:
> public void encodeBegin(FacesContext context, UIComponent component)....
>
> Method Usage in the example:
> {...
> component.encodeBegin(context);
> ...}
>
> Method should be:
> {...
> encodeBegin(context, component)
> ...}
>
> I believe this is correct. There are other places in the code like this as
> well. I believe this is a correct solution/
>
> ---------
> Eric Kelm
> Developer, VSG Worldwide LLC
> Longview, TX 75601
>
> ->-----Original Message-----
> ->From: Curtney Jacobs [mailto:[EMAIL PROTECTED]
> ->Sent: Thursday, July 28, 2005 3:46 AM
> ->To: [EMAIL PROTECTED]
> ->Cc: MyFaces Discussion
> ->Subject: Re: ClassCastException calling encodeBegin
> ->
> ->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.renderJavaScriptAnc
> ->horStart(HtmlLinkRendererBase.java:323)
> -> at
> ->org.apache.myfaces.renderkit.html.HtmlLinkRendererBase.renderCommandLinkSt
> ->art(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
> ->>
> ->>
>
>