You're using makeEventBean to populate your form beans, and both Event and
Course have a primary key property called "ID".  When the success result
from Step.One is fired, Step.Two is run, but all the previous values are
preserved in the request.

In order to make it work in the way you want you'll need to tell ModelGlue
not to preserve those values (you've already saved them to the db anyway)

try..
<result name="success" do="Step.Two" redirect="true" preservestate="fase" />

FWIW, I pass my primary keys in fields that have a name unique to the
object, so EventID or CourseID.  I do this even if the entity's primary key
column is "ID", this avoids any ambiguity.  Then i'll tell controller
methods what the PK variable name is using a message-argument, with a fall
back to a default, eg.

function getSomething(any event) {
  var pk = event.getValue(event.getArgument("pk_var", "SomethingID"));
  var something = beans.SomethingService.get(pk);
  event.setValue("Something", something);
}


Cheers,Chris



On 13 October 2010 16:50, Clifford Moon <[email protected]> wrote:

> Greetings,
>
> I have an application that I'm working on with several tables.  I'm
> using Coldspring to handle all the beans.
>
> I have two tables (Events and Courses).  Each has a bean setup with
> the init, setters and getters in them respectively.  I'm working on a
> form that first requires you to setup an event, and once the event
> data is input and submitted, it moves to the next page which then
> allows you to add courses to the events.
>
> My model glue file is as follows:
> <event-handler name="Step.One" type="templatedPage">
>    <broadcasts>
>         <message name="GetEventForm" />
>   </broadcasts>
>      <views>
>
>      <include name="primary" template="forms/frm_stepone.cfm">
>                 <value name="xe_receiveformat" value="handleStepOne" /
> >
>      </include>
>   </views>
> </event-handler>
>
> <event-handler name="handleStepOne" type="templatedPage">
>    <broadcasts>
>         <message name= "EventFormSubmitted" />
>    </broadcasts>
>
>   <results>
>        <result name="success" do="Step.Two" />
>        <result name="failure" do="EventAdmin.Edit" />
>   </results>
> </event-handler>
>
> <event-handler name="Step.Two" type="templatedPage">
>    <broadcasts>
>          <message name= "GetGenericCourseForm" />
>    </broadcasts>
>
>    <views>
>        <include name="primary" template="forms/frm_steptwo.cfm">
>            <value name="xe_receiveformat"
> value="handleEventAdminForm" />
>        </include>
>     </views>
> </event-handler>
>
> The Controller parts are:
>
> <cffunction name="EventFormSubmitted"  access="public"
> returnType="void" output="false" hint="???">
>   <cfargument name="event" type="any">
>   <cfset var EventsBean =
> getModelGlue().getBean("instanceFactory").getBean("EventsBean") /
> >
>    <cfset var EventsService =
> getModelGlue().getBean( "EventsService") />
>    <cfset var EventsList = EventsService.getEventsList() />
>   <cfset var ErrorStruct = structNew() />
>   <cfset var isValid = false />
>   <cfset arguments.event.makeEventBean( EventsBean ) />
>   <cfset isValid = EventsBean.validate (ErrorStruct) />
>
>   <cfif isValid >
>        <cfset EventsService.saveEvent( EventsBean ) />
>        <cfset arguments.event.addResult("Success") />
>   <cfelse>
>      <cfset arguments.event.setValue("ErrorStruct", ErrorStruct) />
>     <cfset arguments.event.addResult("Failure") />
>   </cfif>
> </cffunction>
>
> <cffunction name="GetGenericCourseForm" access="public"
> returnType="void" output="false" hint="???">
>    <cfargument name="event" type="any">
>    <cfset var CoursesBean = "" />
>    <cfset var CoursesBean =
> getModelGlue().getBean("instanceFactory").getBean("CoursesBean") />
>    <cfset arguments.event.makeEventBean( CoursesBean ) />
>    <cfset arguments.event.setValue( "CoursesBean", CoursesBean ) />
> </cffunction>
>
> My Problem is in between forms/frm_stepone.cfm and forms/
> frm_stepTwo.cfm (Step.One and Step.Two events respectively), I write
> what was in the EVENTS  bean to the EVENTS table, and then create a
> bean for COURSES.
>
> In my form (frm_stepTwo.cfm), here is the first part of the form:
>
> <cfset event.copyToScope(variables,"xe_receiveformat") />
> <cfset myself = viewstate.getValue("myself") />
> <cfset CoursesBean = viewstate.getValue("CoursesBean") />
> <cfset ErrorStruct = viewstate.getValue("ErrorStruct", structNew()) />
> <cfset submit = event.linkTo(xe_receiveformat) />
>
>
>
> <cfoutput>
> <cfform name="CoursesForm" id="CoursesForm" action="#submit#">
>   <input type="hidden" name="id" value="#CoursesBean.getID()#">
>   <input type="hidden" name="create_date" value="#now()#">
>
>
> When i Go to get the value of CoursesBean.getID and assume it to be
> zero (as I havent created a record or anything yet there), I'm getting
> the value of what was in the EventsBean.getID().
>
> Why is CoursesBean.getID picking up the value of EventsBean.getID().
>
> I have them both defined in my coldspring.xml as follows:
>
> <bean id="EventsBean" class="aa.EventManagement.model.EventsBean"
> singleton="false" />
> <bean id="CoursesBean" class="aa.EventManagement.model.CoursesBean"
> singleton="false" />
>
> Any help is greatly appreciated.
>
> Thanks in Advance,
>
> Cliff
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to