[jboss-user] [JBoss Seam] - Re: Submitting using SelectOneRadio
monkeyden
do-not-reply at jboss.com
Mon Oct 30 16:21:29 EST 2006
I've implemented a ValueChangeListener, to handle the change of the radio button, but I'm not sure how to change the value in my Seam component, to reflect the value change. I'm sure I am supposed to be looking up the Seam component a different way, since it fails with a ClassCastException when I try to get the Seam component from FacesContext.
The question now is, in what way is this code different when we're dealing with Seam components (SFSBs) vs. standard JSF managed beans? It finds the component just fine, and even tells me the beanClass is com.project.actions.EditUserRecordAction.
Here is the code:
package com.project.util;
|
| import javax.faces.application.Application;
| import javax.faces.context.FacesContext;
| import javax.faces.event.AbortProcessingException;
| import javax.faces.event.ValueChangeEvent;
| import javax.faces.event.ValueChangeListener;
|
| import com.project.actions.EditUserRecordAction;
|
| public class StateSelectorChangeListener implements ValueChangeListener {
|
| public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
| FacesContext facesContext = FacesContext.getCurrentInstance();
| Application app = facesContext.getApplication();
| Object myObj = app.getVariableResolver().resolveVariable(facesContext, "editProfileAction");
| try {
| EditUserRecordAction editRecordBean = (EditUserRecordAction)myObj;
| editRecordBean.setSelectedState((String)event.getNewValue());
| } catch (RuntimeException e) {
| e.printStackTrace();
| }
| }
|
| }
|
@Stateful
| @Name("editProfileAction")
| @Scope(SESSION)
| public class EditUserRecordAction implements EditUserRecord, Serializable {
| ...
| public void setSelectedState(String selectedState){
| this.selectedState = selectedState;
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981870#3981870
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981870
More information about the jboss-user
mailing list