[jboss-user] [JBoss Seam] - Re: No selected element from <h:selectOneListbox>

haefti do-not-reply at jboss.com
Mon Jan 14 06:22:00 EST 2008


Hi!
First of all thanks for the answer!

"jmodadams" wrote : I believe the problem here is that you have not specified a value attribute in the h:selectOneListbox tag, which is how you bind the selected value to your backing bean.
  | 
  | If you were to add a video property to your manager bean with a public setter method, you could then do the following:
  | 
Okay, I thought I could inject it via @In or @DataModelSelection or something similar.

My managerAction now looks like this:

  | @Stateless
  | @Name("manager")
  | public class ManagerAction implements Manager{
  | 
  | 	@Logger
  | 	Log log;
  | 
  | 	private Video selVideo;	
  |   
  | 	public Video getselVideo() {
  | 		return selVideo;
  | 	}
  | 
  | 	public void setSelVideo(Video selVideo) {
  | 		this.selVideo = selVideo;
  | 	}
  | 
  | 	public String editVideo () {
  | 		log.info("selected video Id: " + selVideo.getVideoId());
  | 		return "edit";
  | 	}
  | .
  | .
  | .
  | }
  | 
the hello.xhtml contains this code:

  | <h:form>
  | 
  | <h:selectOneListbox size="10" value="#{manager.selVideo}">
  |   <s:selectItems value="#{videos}" var="video" disabled="#{video.videoId < 25000 ? true : false}"
  |    label="(#{video.datum}) #{video.videoId} - #{video.thema}: #{video.headline}" />
  |   <s:convertEntity />
  | </h:selectOneListbox>
  | 
  | <h:commandButton type="submit" action="#{manager.editVideo()}" value="Ändern"></h:commandButton>
  |                  
  | </h:form>
  | 
and I added this to my pages.xml:

  | 	<page view-id="/hello.xhtml">
  |     
  | 	    <navigation from-action="#{manager.editVideo}">
  | 	        <rule if-outcome="edit">
  | 	            <redirect view-id="/edit.xhtml"/>
  | 	        </rule>
  | 	    </navigation>
  |     
  | 	</page>
  | 
but if I choose an item from the list and press the button I still get back to the hello.xhtml and do not get the log output of the editVideo() method.
If I don't choose anything and press the button I get an (expected) NullPointerException from the method editVideo() because selVideo is null can not be logged.

Any idea?

Thanks!

Haefti

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119573#4119573

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119573




More information about the jboss-user mailing list