Strange Behavior 2.0.1.GA Date Object
nathandennis Mar 26, 2008 4:03 AMhey guys. i have been putting together a faily complex little app that makes use of seam 2.0.1.GA and richfaces 3.1.4. for the past few days,, i thought the issue was richfaces.. and im still not convinced its not... but i need the gurus to confirm and at least help me pin point the source of the strange behavior and describe it. So strange that until now, i couldnt even formulate the question without contradicting myself with a working example.
The problem is dealing with the rich calendar object..(and i have exhausted every resource on this already,, and even dug through some source.) code is worth a thousand words,,
a broken example.
@Local public interface TimelineLocal { public Date getEventDob(); public void setEventDob(Date eventdob); ... @Stateful @Name("timelineAction") @Scope(ScopeType.CONVERSATION) public class TimelineAction implements TimelineLocal, DropListener {... /**called when we want the a save function based on a give panel * */ public void eventPanelInit(int eventpanelselect, boolean eventwizard){ this.eventpanelselect = eventpanelselect; this.eventwizard = eventwizard; } public void saveEvent(int panelselect){ log.info(panelselect); switch (panelselect) { case 0: //do something break; case 1: Events newevent = new Events(); Calendar dobcal2 = Calendar.getInstance(); dobcal2.setTime(this.eventdob); newevent.setEventdob(this.eventdob); ......... break; default: queryTimeline(); cancelEvent(); } } @Temporal(TemporalType.DATE) @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public Date getEventDob(){ return this.eventdob; } @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setEventDob(Date eventdob){ Calendar ed = Calendar.getInstance(); ed.setTime(eventdob); newevent.setEventday((long) ed.get(Calendar.DAY_OF_MONTH) ); newevent.setEventmonth((long) ed.get(Calendar.MONTH)); newevent.setEventyear((long) ed.get(Calendar.YEAR)); newevent.setEventxpos((long) ((ed.get(Calendar.YEAR)-byear)*YEARLEFTDEFAULT + ed.get(Calendar.MONTH)*MONTHWIDTH + 15 + ed.get(Calendar.DAY_OF_MONTH)*DAYWIDTH)); this.eventdob = ed.getTime(); ed = null; }
main xhtml and insert
<h:form> .... <div style="position:absolute; top: 375px; width:600px; float:left;"> <a:commandButton actionListener="#{timelineAction.locationPersist}" value="Save Timeline"> <s:conversationId/> </a:commandButton> <a:commandButton actionListener="#{timelineAction.eventPanelInit(1, true)}" value="New Text Event" oncomplete="rerenderEventWizard();"> <s:conversationId/> </a:commandButton> </div> </a:outputPanel> </div> </h:form> <h:panelGroup id="eventwizard"> <ui:include src="include/event.xhtml" /> </h:panelGroup> *********EOF** *****the insert********* <rich:modalPanel id="eventmp" minHeight="500" minWidth="450" top="20" style="padding:0px;"> <f:facet name="header" style="height:20px;"> <h:outputText value="Event Details" /> </f:facet> <h:form> <a:outputPanel id="eventcontainer"> <rich:messages/> <a:region> <table><tr><td>Date: </td> <td> <rich:calendar id="modeventdate" value="#{timelineAction.eventDob}" datePattern="MM/dd/yyyy" inputSize="20" enableManualInput="true" popup="true" inputStyle="padding:2px;padding-left:4px" immediate="true" mode="ajax"> <a:support event="ondateselected" /> </rich:calendar> </td> </tr> ........ <tr><td> <a:commandButton id="comand2" rendered="#{timelineAction.eventpanelselect == 9}" actionListener="#{timelineAction.saveEvent(timelineAction.eventpanelselect)}" value="Save Event"> <s:conversationId/> </a:commandButton> </td> <td> <a:commandButton id="comand3" actionListener="#{timelineAction.cancelEvent}" value="Cancel" ajaxSingle="true" oncomplete="Richfaces.hideModalPanel('eventmp');"> <s:conversationId/> </a:commandButton> </td> </tr> </table> </a:region> </a:outputPanel> </h:form> </div> </div> </rich:modalPanel> *********EOF********
and the error
22:47:28,199 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=j_id65:modeventdate[severity=(ERROR 2), summary=(/timeline/include/event.xhtml @46,36 value="#{timelineAction.eventDob}": Error writing 'eventDob' on type org.javassist.tmp.java.lang.Object_$$_javassist_16), detail=(/timeline/include/event.xhtml @46,36 value="#{timelineAction.eventDob}": Error writing 'eventDob' on type org.javassist.tmp.java.lang.Object_$$_javassist_16)]
thats the whole stack dump.. looked at it with firebug and everything is being sent ok,, just will not execute the saveEvent method after the bogus i can write to Date because im a moron
error message.
here is what blows my mind.
if i instantiate the entity newevent
before i load the modalPanel.. the bloody thing work fine.
some working code. (everything un touched except for adding a method and two lines of alterations to the old code.
@Stateful @Name("timelineAction") @Scope(ScopeType.CONVERSATION) public class TimelineAction implements TimelineLocal, DropListener {... /**called when we want the a save function based on a give panel * */ public void eventPanelInit(int eventpanelselect, boolean eventwizard){ this.eventpanelselect = eventpanelselect; this.eventwizard = eventwizard; /* attention HERE*/ startTextEvent(); } public void startTextEvent(){ this.eventdob = Calendar.getInstance().getTime(); newevent = new Events(); newevent.setEventdob(this.eventdob) } public void saveEvent(int panelselect){ log.info(panelselect); switch (panelselect) { case 0: //do something break; case 1: /*Attention HERE.. commented out*/ //Events newevent = new Events(); Calendar dobcal2 = Calendar.getInstance(); dobcal2.setTime(this.eventdob); newevent.setEventdob(this.eventdob); ......... break; default: queryTimeline(); cancelEvent(); } } @Temporal(TemporalType.DATE) @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public Date getEventDob(){ return this.eventdob; } @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setEventDob(Date eventdob){ Calendar ed = Calendar.getInstance(); ed.setTime(eventdob); newevent.setEventday((long) ed.get(Calendar.DAY_OF_MONTH) ); newevent.setEventmonth((long) ed.get(Calendar.MONTH)); newevent.setEventyear((long) ed.get(Calendar.YEAR)); newevent.setEventxpos((long) ((ed.get(Calendar.YEAR)-byear)*YEARLEFTDEFAULT + ed.get(Calendar.MONTH)*MONTHWIDTH + 15 + ed.get(Calendar.DAY_OF_MONTH)*DAYWIDTH)); this.eventdob = ed.getTime(); ed = null; }
no change to the xhtmls and the thing run flawlessly.
i originally thought that the problem was linked to rich:calendar directed at a session bean... i know that shouldnt matter... but it was just the observation. but at this point im not convinced.
what is happening here? is this a seam bug or a richfaces bug? if richfaces... can someone help me document it or help me understand what exactly is breaking so i can file a jira issue?
thanks for any direction.