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#a6960741
Sent from the MyFaces - Users mailing list archive at Nabble.com.