Title: RE: Form State after validation
Thread: Form State after validation
Forum: Need Help?
Conference: ColdBox
User: CraigHeneveld Here is my code.
[code]
<cffunction name="dspProductView" access="public"
returntype="void" output="false">
<cfargument name="Event"
type="shared.frameworks.coldbox_2_50.coldbox.system.beans.requestContext">
<cfargument name="product" type="Any" required="false">
<cfset var rc =
Event.getCollection() />
<cfset rc.title= getSetting("title") & " | Product">
<cfset rc.xehCommit= "index.cfm?event=ehAdmin.doEditProduct">
<cfif
isDefined("arguments.product")>
<cfset rc.record= arguments.product>
<cfelse>
<cfset rc.record= rc.ProductManager.getProductByID(rc.product_id)>
</cfif>
<cfset rc.qCategory= rc.ProductManager.getCategories()>
<cfset
rc.qSize= rc.ProductManager.getSizes()>
<cfset rc.qCombination =
rc.ProductManager.getCombinations()>
<cfset
Event.setView("private/vwProduct")>
</cffunction>
<cffunction
name="doEditProduct" access="public" returntype="void" output="false">
<cfargument name="Event"
type="shared.frameworks.coldbox_2_50.coldbox.system.beans.requestContext">
<cfset var rc = Event.getCollection() />
<cfset var Errors = "">
<cfset
var validator = rc.validator.isEmpty(rc.title,"Enter a title.","yes", "title")>
<cfset var oProduct = rc.ProductManager.getProductByID(rc.product_id)>
<cfset validator = rc.validator.isEmpty(rc.price,"Enter a price.","yes",
"price")>
<cfset Errors = rc.validator.getErrors() />
<cfif NOT
StructIsEmpty(Errors)>
<cfset getPlugin("messagebox").setMessage("error",
rc.validator.getErrorDialog())>
<cfset
getPlugin("beanFactory").populateBean(oProduct)>
<cfset
dspProductView(Event,oProduct)>
<cfelse>
<!---DO SOME STUFF--->
<cfset getPlugin("beanFactory").populateBean(oProduct)>
<cfset
rc.Transfer.save(oProduct)>
<cfset
getPlugin("messagebox").setMessage("info", "You have just created a product!")>
<cfset setNextEvent("ehAdmin.dspProductList")>
</cfif>
[/code]
I have issues with this sometimes. Right before I call [code]<cfset
Event.setView("private/vwProduct")>[/code]The state of the record is fine. But
when in the view I lose statefullyness.
Am I missing something here?
http://www.luismajano.com/forums/index.cfm?event=ehMessages.dspMessages&threadid=8480352C-FF65-CEF6-654286259664EA8D