[jboss-user] [JBoss Seam] - Problem with entity in session scope and JSF inputText

amitdk do-not-reply at jboss.com
Sat Jun 23 22:02:16 EDT 2007


I've spent too much time on this so far and am wondering if conceptually I am doing something wrong. I would imagine this to be a fairly common use case for folks, so here's the issue:
Here's a snippet of my xhtml page - 

  | 				<s:decorate template="layout/edit.xhtml">
  | 					<ui:define name="label">Timeline</ui:define>
  | 					<h:selectOneMenu id="timeline" value="#{task.selectedTimeline}" required="false" 
  | 						immediate="true">
  | 						<f:valueChangeListener type="com.edwardjones.statusreporting.view.TimelineChangeListener" />
  | 						<s:selectItems id="timelinelst" value="#{timelineList}" 
  | 							var="timeline" label="#{timeline.description}" />							
  | 						<s:convertEntity />
  | 						<a:support event="onchange" reRender="dt"/>
  | 					</h:selectOneMenu>
  | 				</s:decorate>
  | 
  | 				<h:inputText id="dt"
  | 				           value="#{selectedTimeline.startDate}">
  | 				    <f:convertDateTime pattern="MM/dd/yyyy"/>
  | 				</h:inputText>
  | 				
  | 				<jp:popupCalendar id="date_popup"
  | 				                    for="date" 
  | 				                    format="MM/dd/yyyy"
  | 				                    rendered="#{!disabled and rendered != false}">
  | 				    <h:graphicImage url="img/calendar.gif"
  | 				                  title="Click here to select date"/>
  | 				</jp:popupCalendar>
  | 

The TimelineChangeListener is as follows:

  | @Name("timelinechange")
  | public class TimelineChangeListener implements ValueChangeListener 
  | {
  |     @Out(value="selectedTimeline", required = false, scope = SESSION)
  |     Timeline timeline;
  |             
  | 	public void processValueChange(ValueChangeEvent arg0)
  | 			throws AbortProcessingException {
  |         timeline = (Timeline) arg0.getNewValue();
  | 
  | 		// TODO Auto-generated method stub
  | 		System.out.println("timeline selection");
  | 	}
  | }
  | 

The Timeline entity looks as follows:

  | /**
  |  * Timeline generated by hbm2java
  |  */
  | @Entity
  | @Name("timeline")
  | @Role(name="selectedTimeline", scope=SESSION)
  | @Table(name = "timeline", catalog = "statreport", uniqueConstraints = @UniqueConstraint(columnNames = "description"))
  | public class Timeline implements java.io.Serializable
  | {
  |     private int id;
  | 
  |     private String description;
  | 
  |     public Timeline()
  |     {
  |     }
  | 
  |     public Timeline(int id, String description)
  |     {
  |         this.id = id;
  |         this.description = description;
  |     }
  | 
  |     @Id
  |     @Column(name = "id", unique = true, nullable = false)
  |     @NotNull
  |     public int getId()
  |     {
  |         return this.id;
  |     }
  | 
  |     public void setId(int id)
  |     {
  |         this.id = id;
  |     }
  | 
  |     @Column(name = "description", unique = true, nullable = false, length = 20)
  |     @NotNull
  |     @Length(max = 20)
  |     public String getDescription()
  |     {
  |         return this.description;
  |     }
  | 
  |     public void setDescription(String description)
  |     {
  |         this.description = description;
  |     }
  | 
  |     @Transient
  |     public Date getStartDate()
  |     {
  |         Calendar startCal = Calendar.getInstance();
  |         // Determine start of week
  |         if (getDescription() == null || getDescription().equals("Weekly"))
  |         {
  |             System.out.println("Weekly timeline");
  |         }
  |         else if ( getDescription().equals("Monthly"))
  |         {
  |             System.out.println("Monthly timeline");
  |         }
  |         // Convert calender to date
  |         Date startDate = startCal.getTime();
  |         return startDate;
  |     }
  | 
  |     @Transient
  |     public Date getEndDate()
  |     {
  |         Calendar startCal = Calendar.getInstance();
  |         if (getDescription() == null || getDescription().equals("Weekly"))
  |         {
  |           ...........
  |         }
  |         return endDate;
  |     }
  | }
  | 
  | 

The ajax support tag calls the timelinechangelistener which sets the selected timeline and puts it into a session scope. Since the rendered element calls the selected timeline getStartDate method, I expected the selected timeline to get passed in, however the timeline on which the getStartDate is called is never selectedTimeline. Hopefully, made things clear as to what I am trying to accomplish. In short, based on the selected timeline, I would like to change the start date/end date logic.

Any help is appreciated....

Thanks
Amit Karandikar


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

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



More information about the jboss-user mailing list