For Tomahawk?

Alex Brown-4 wrote:
> 
> FYI, there is a link to it (src) on the download page next to the binary. 
> It is a zip file.
> 
> ________________________________
> 
> From: monkeyden [mailto:[EMAIL PROTECTED]
> Sent: Mon 10/23/2006 6:55 PM
> To: users@myfaces.apache.org
> Subject: Re: Getting a reference to my backing bean in TabChangeListener
> 
> 
> 
> 
> I wouldn't say it's "very accessible" unless:
> 
> [1] There is a link to it on the download page (right next to the link to
> the binaries, I might add)
> [2] I can download it as a zip file, to allow me to step through it in my
> debugger.
> 
> and I don't have to:
> [3] View Java code from my browser (icky!)
> [4] Rebuild the source tree myself, to step through it.
> 
> Disclaimer: Square brackets ([]) provided not for sarcasm, but
> readability.
> :)
> 
> 
> Jeff Bischoff wrote:
>>
>> Oh please don't waste your time decompiling! The source is very
>> accessible. :)
>>
>> [1] Is the project website
>> [2] Is the download page, with source code for *some* of the releases
>> [3] Is the SVN repository (online access) for getting the source code
>> directly
>>
>> Now you can see what's at line 82! :D
>>
>> [1] http://myfaces.apache.org/
>> [2] http://myfaces.apache.org/download.html
>> [3] http://svn.apache.org/repos/asf/myfaces/
>>
>> Regards,
>>
>> Jeff Bischoff
>> Kenneth L Kurz & Associates
>>
>> monkeyden wrote:
>>> I decompiled the class file for this tag (tomahawk v1.1.3) and found
>>> that
>>> there are only two places where casting is done (don't know the line
>>> numbers
>>> as it's decompiled code). 
>>>
>>> 1.  TabChangeListener listener =
>>> (TabChangeListener)ClassUtils.newInstance(className);
>>> 2.  ((HtmlPanelTabbedPane)component).addTabChangeListener(listener);
>>>
>>> Clearly my tab listener won't result in a ClassCastException, because it
>>> implements TabChangeListener, which leaves the HtmlPanelTabbedPane cast.
>>> This doesn't appear possible either since the following code is being
>>> used:
>>>
>>> <t:panelTabbedPane id="tabbedPane" width="650"
>>> serverSideTabSwitch="true"
>>> selectedIndex="#{editProfileAction.selectedTab}" >
>>>     ...
>>>     <t:tabChangeListener
>>> type="com.nemoves.pipeline.util.EditUserRecordTabListener"/>
>>> </t:panelTabbedPane>
>>>
>>>
>>>
>>>
>>> monkeyden wrote:
>>>> Thanks for the reply Jeff. 
>>>>
>>>> I am currently trying this but getting a ClassCastException when the
>>>> tabChangeListener tag is encountered.  Does anyone know where I can
>>>> find
>>>> the source for tomahawk, so I can step through int he debugger?  Only
>>>> bin
>>>> is available here:  http://www.wmwweb.com/apache/myfaces/
>>>> http://www.wmwweb.com/apache/myfaces/
>>>>
>>>> java.lang.ClassCastException: com.site.util.EditUserRecordTabListener
>>>>     at
>>>> org.apache.myfaces.custom.tabbedpane.TabChangeListenerTag.doStartTag(TabChangeListenerTag.java:82)
>>>>
>>>> Here is the code:
>>>>
>>>> package com.site.util;
>>>>
>>>> import javax.faces.context.FacesContext;
>>>> import javax.faces.el.ValueBinding;
>>>> import javax.faces.event.AbortProcessingException;
>>>>
>>>> import org.apache.myfaces.custom.tabbedpane.TabChangeEvent;
>>>> import org.apache.myfaces.custom.tabbedpane.TabChangeListener;
>>>>
>>>> import com.site.actions.EditUserRecordAction;
>>>>
>>>> public class EditUserRecordTabListener implements TabChangeListener {
>>>>
>>>>     public void processTabChange(TabChangeEvent event) throws
>>>> AbortProcessingException {
>>>>         int newIndex = event.getNewTabIndex();
>>>>         int oldIndex = event.getNewTabIndex();
>>>>         EditUserRecordAction action =
>>>> (EditUserRecordAction)getManagedBean("editProfileAction");
>>>>         action.setSelectedTab(newIndex);
>>>>     }
>>>>    
>>>>     public static Object getManagedBean(String ref) {
>>>>         // Find or create the web-tier data object
>>>>         // ref like "#{myBean}"
>>>>         FacesContext context = FacesContext.getCurrentInstance();
>>>>         ValueBinding binding =
>>>> context.getApplication().createValueBinding(ref);
>>>>         Object result = binding.getValue(context);
>>>>         return result;
>>>>     }
>>>>
>>>> }
>>>>
>>>>
>>>> Jeff Bischoff wrote:
>>>>> Monkeyden,
>>>>>
>>>>> See [1]. This is from the front page of the wiki.
>>>>>
>>>>> Alternatively, all managed beans can be accessed directly from the
>>>>> appropriate scope (i.e. request, session).
>>>>>
>>>>> I found the following utility method (based on the wiki page) useful
>>>>> in
>>>>> my application:
>>>>>
>>>>> /**
>>>>> * Look up a managed bean by JSP-EL value-binding expression
>>>>> * @param ref a value-binding expression to lookup
>>>>> * @return the managed bean referenced by the expression
>>>>> */
>>>>> public static Object getManagedBean(String ref) {
>>>>>    // Find or create the web-tier data object
>>>>>    // ref like "#{myBean}"
>>>>>    FacesContext context = FacesContext.getCurrentInstance();
>>>>>    ValueBinding binding =
>>>>> context.getApplication().createValueBinding(ref);
>>>>>    return binding.getValue(context);
>>>>> }
>>>>>
>>>>> [1] http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
>>>>>
>>>>> Regards,
>>>>>
>>>>> Jeff Bischoff
>>>>> Kenneth L Kurz & Associates, Inc.
>>>>>
>>>>> monkeyden wrote:
>>>>>> Im using a Tomahawk tabbedPane in my JSP
>>>>>>
>>>>>> <t:panelTabbedPane id="tabbedPane" bgcolor="#ffffff" width="650"
>>>>>> serverSideTabSwitch="true"
>>>>>> selectedIndex="#{myBackingBean.selectedTab}">
>>>>>>
>>>>>> I want to implement a TabChangeListener, to set the "selectedTab"
>>>>>> value
>>>>>> of
>>>>>> the backing bean.  I don't need to change the view of the component
>>>>>> at
>>>>>> all,
>>>>>> since that's handled automatically.  I just need to know what the
>>>>>> currently
>>>>>> selected tab is.  Looking at the hierarchy, there doesn't seem to be
>>>>>> a
>>>>>> way
>>>>>> to get my backing bean instance from session to set the value.  This
>>>>>> is
>>>>>> how
>>>>>> I would expect this to be done.  Please tell me if I'm way off base
>>>>>> or
>>>>>> not.
>>>>>>
>>>>>> processTabChange(TabChangeEvent tabChangeEvent){
>>>>>>     MyBackingBean myBean = [get the bean somehow];
>>>>>>     myBean.setSelectedTab(tabChangeEvent.getNewTabIndex());
>>>>>> }
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>>
>>
>>
> 
> --
> View this message in context:
> http://www.nabble.com/Getting-a-reference-to-my-backing-bean-in-TabChangeListener-tf2495151.html#a6963901
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> 
> 
> 
> 
>  
> 

-- 
View this message in context: 
http://www.nabble.com/Getting-a-reference-to-my-backing-bean-in-TabChangeListener-tf2495151.html#a6977227
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to