|
View:
New views
12 Messages
—
Rating Filter:
Alert me
|
|
|
Global Application NameThis is a best practices question. I want to be able to set my Application Display Name one place and reference it whereever I want. application.applicationname seems completely wrong from an object oriented stand point yet I haven't been able to find any reference to a differenct technique anywhere and there isn't a model glue variable for it that I'm aware.
How do you handle this? |
|
|
Re: Global Application NameI don't know if this is best practice, but in ColdSpring.xml I have a
siteDetails bean: <!-- Site Constants --> <bean id="siteDetails" class="ModelGlue.Bean.CommonBeans.SimpleConfig"> <property name="config"> <!-- In Coldspring, a "map" represents a struct --> <map> <entry key="favicon"><value>favicon.ico</value></entry> <entry key="siteName"><value>MySite</value></entry> <entry key="siteStyleSheet"><value>/css/v3/eurstart.css</value></entry> etc... In any of your views you can call it like: #viewState.GetValue("siteDetails").siteNamer# I have a similar xe bean in ColdSpring.xml for all my exit points. I hope this helps. Regards, Richard On 11/28/06, Bryan S <bryansgroups@...> wrote: > This is a best practices question. I want to be able to set my Application > Display Name one place and reference it whereever I want. > application.applicationname seems completely wrong from an object oriented > stand point yet I haven't been able to find any reference to a differenct > technique anywhere and there isn't a model glue variable for it that I'm > aware. > > How do you handle this? > --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
Re: Global Application NameSorry, I added a typo when calling the constant. I should have wrote this:
#viewState.GetValue("siteDetails").siteName# On 11/28/06, Richard East <richard.east@...> wrote: > I don't know if this is best practice, but in ColdSpring.xml I have a > siteDetails bean: > > <!-- Site Constants --> > <bean id="siteDetails" class="ModelGlue.Bean.CommonBeans.SimpleConfig"> > <property name="config"> > <!-- In Coldspring, a "map" represents a struct --> > <map> > <entry key="favicon"><value>favicon.ico</value></entry> > <entry key="siteName"><value>MySite</value></entry> > <entry key="siteStyleSheet"><value>/css/v3/eurstart.css</value></entry> > etc... > > In any of your views you can call it like: > #viewState.GetValue("siteDetails").siteNamer# > > I have a similar xe bean in ColdSpring.xml for all my exit points. > > I hope this helps. > > Regards, > > Richard > > On 11/28/06, Bryan S <bryansgroups@...> wrote: > > This is a best practices question. I want to be able to set my Application > > Display Name one place and reference it whereever I want. > > application.applicationname seems completely wrong from an object oriented > > stand point yet I haven't been able to find any reference to a differenct > > technique anywhere and there isn't a model glue variable for it that I'm > > aware. > > > > How do you handle this? > > > > > --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
Re: Global Application NameOn 11/28/06, Richard East <richard.east@...> wrote:
> I hope this helps. Richard It was very helpful, sort of. :-) It showed me that I was on the right path with what I was trying to do. Unfortunately it doesn't work. The view says "You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members." with this code. in my view <cfoutput>#viewState.GetValue("siteDetails").siteName#</cfoutput> in coldspring.xml <bean id="siteDetails" class="ModelGlue.Bean.CommonBeans.SimpleConfig"> <property name="config"> <map> <entry key="favicon"><value> favicon.ico</value></entry> <entry key="siteName"><value>MySite</value></entry> <entry key="siteStyleSheet"><value>/css/v3/eurstart.css</value></entry> </map> </property> </bean> The object isn't showing up when I dump this either. <cfdump var="#viewstate.getAll()#" label="viewstate.getAll()"> <cfdump var="#viewcollection#" label="viewcollection"> |
|
|
Re: Global Application NameHi Bryan,
I'm away from my office pc, so cannot quickly answer this. The bean needs to be initiated in the main controller cfc you use. I can't give you the exact code at the moment, but I will forward it as soon as I can unless someone else on the list can beat me to it. Sorry, Richard On 11/28/06, Bryan S <bryansgroups@...> wrote: > On 11/28/06, Richard East <richard.east@...> wrote: > > > I hope this helps. > > > Richard > > It was very helpful, sort of. :-) It showed me that I was on the right path > with what I was trying to do. Unfortunately it doesn't work. > > The view says > "You have attempted to dereference a scalar variable of type class > java.lang.String as a structure with members." > > with this code. > > in my view > <cfoutput>#viewState.GetValue("siteDetails").siteName#</cfoutput> > > in coldspring.xml > <bean id="siteDetails" > class="ModelGlue.Bean.CommonBeans.SimpleConfig"> > <property name="config"> > <map> > <entry key="favicon"><value> favicon.ico</value></entry> > <entry > key="siteName"><value>MySite</value></entry> > <entry > key="siteStyleSheet"><value>/css/v3/eurstart.css</value></entry> > </map> > </property> > </bean> > > The object isn't showing up when I dump this either. > <cfdump var="#viewstate.getAll()#" label="viewstate.getAll()"> > <cfdump var="#viewcollection#" label="viewcollection"> > > --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
RE: Global Application NameYeah I have something similar, I'm not very happy with it but it works for
now. <bean id="site" class="beans.Site" singleton="false"> <property name="name"><value>Site Name</value></property> <property name="DSN"><value>Datasource name</value></property> <property name="path"><value>Absolute path</value></property> <property name="clientURL"><value>url for the client interface</value></property> <property name="adminURL"><value>url for the admin interface</value></property> </bean> Then this can be referenced in your controllers manually or inject it <cfscript> // Manual reference to site configuration var site = GetModelGlue().GetBean("site"); // To access a property just call the method var siteName = site.getName(); // send it back to the viewstate Arguments.event.setValue('siteName', siteName); </cfscript> Hopefully that's what you were looking for. - Roy --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
RE: Global Application NameNote: There was an error in that code that I didn't see before. Singleton
should be equal to true not false since there is no reason to have multiple instances of this floating around. <bean id="site" class="beans.Site" singleton="true"> - Roy --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
Re: Global Application NameBryan,
If you put this in the Controller.cfc, it should work: <cffunction name="setSiteDetails" access="public" returnType="void" hint="I get the constants of this site"> <cfargument name="siteDetails" /> <cfset variables._siteDetails = arguments.siteDetails /> </cffunction> And change the onQueueComplete function in the Controller.cfc: <cffunction name="onQueueComplete" access="public" returnType="void" output="false"> <cfargument name="event" type="any" /> <cfset arguments.event.setValue("siteDetails", variables._sitedetails.getConfig()) /> </cffunction> Regards, Richard On 11/28/06, Richard East <richard.east@...> wrote: > Hi Bryan, > > I'm away from my office pc, so cannot quickly answer this. The bean > needs to be initiated in the main controller cfc you use. I can't give > you the exact code at the moment, but I will forward it as soon as I > can unless someone else on the list can beat me to it. > > Sorry, > > Richard > > > > On 11/28/06, Bryan S <bryansgroups@...> wrote: > > On 11/28/06, Richard East <richard.east@...> wrote: > > > > I hope this helps. > > > > > > Richard > > > > It was very helpful, sort of. :-) It showed me that I was on the right path > > with what I was trying to do. Unfortunately it doesn't work. > > > > The view says > > "You have attempted to dereference a scalar variable of type class > > java.lang.String as a structure with members." > > > > with this code. > > > > in my view > > <cfoutput>#viewState.GetValue("siteDetails").siteName#</cfoutput> > > > > in coldspring.xml > > <bean id="siteDetails" > > class="ModelGlue.Bean.CommonBeans.SimpleConfig"> > > <property name="config"> > > <map> > > <entry key="favicon"><value> favicon.ico</value></entry> > > <entry > > key="siteName"><value>MySite</value></entry> > > <entry > > key="siteStyleSheet"><value>/css/v3/eurstart.css</value></entry> > > </map> > > </property> > > </bean> > > > > The object isn't showing up when I dump this either. > > <cfdump var="#viewstate.getAll()#" label="viewstate.getAll()"> > > <cfdump var="#viewcollection#" label="viewcollection"> > > > > > > > --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
Re: Global Application NameO.K. Thanks. I am autowiring the new object in my Controller. I don't know if there is something additional I need to do for your code to work.
On 11/28/06,
Richard East <richard.east@...> wrote:
Hi Bryan, |
|
|
Re: Global Application NameRichard
I'm pretty close because I can do this in my Controller and get the correct value <cfset test = getSiteDetails().getConfigSetting("siteName")> <cfdump var="#test#" label="test"><cfabort> So it must just be something little that is causing this to give the error in my view <cfset appTitle = viewState.GetValue("siteDetails").siteName /> Bryan
On 11/28/06, Richard East <richard.east@...> wrote: Hi Bryan, |
|
|
Re: Global Application NameHi Bryan,
I'm not sure if Topica is sending emails in the right order, but... This line from my previous email in the onQueueComplete in Controller.cfc puts the constant into the view state: <cfset arguments.event.setValue("siteDetails", variables._sitedetails.getConfig()) /> Regards, Richard My last message: Bryan, If you put this in the Controller.cfc, it should work: <cffunction name="setSiteDetails" access="public" returnType="void" hint="I get the constants of this site"> <cfargument name="siteDetails" /> <cfset variables._siteDetails = arguments.siteDetails /> </cffunction> And change the onQueueComplete function in the Controller.cfc: <cffunction name="onQueueComplete" access="public" returnType="void" output="false"> <cfargument name="event" type="any" /> <cfset arguments.event.setValue("siteDetails", variables._sitedetails.getConfig()) /> </cffunction> Regards, Richard On 11/28/06, Richard East <richard.east@...> wrote: > Bryan, > > If you put this in the Controller.cfc, it should work: > > <cffunction name="setSiteDetails" access="public" returnType="void" > hint="I get the constants of this site"> > <cfargument name="siteDetails" /> > <cfset variables._siteDetails = arguments.siteDetails /> > </cffunction> > > And change the onQueueComplete function in the Controller.cfc: > <cffunction name="onQueueComplete" access="public" returnType="void" > output="false"> > <cfargument name="event" type="any" /> > <cfset arguments.event.setValue("siteDetails", > variables._sitedetails.getConfig()) /> > </cffunction> > > Regards, > > Richard > > On 11/28/06, Richard East <richard.east@...> wrote: > > Hi Bryan, > > > > I'm away from my office pc, so cannot quickly answer this. The bean > > needs to be initiated in the main controller cfc you use. I can't give > > you the exact code at the moment, but I will forward it as soon as I > > can unless someone else on the list can beat me to it. > > > > Sorry, > > > > Richard > > > > > > > > On 11/28/06, Bryan S <bryansgroups@...> wrote: > > > On 11/28/06, Richard East <richard.east@...> wrote: > > > > > I hope this helps. > > > > > > > > > Richard > > > > > > It was very helpful, sort of. :-) It showed me that I was on the right path > > > with what I was trying to do. Unfortunately it doesn't work. > > > > > > The view says > > > "You have attempted to dereference a scalar variable of type class > > > java.lang.String as a structure with members." > > > > > > with this code. > > > > > > in my view > > > <cfoutput>#viewState.GetValue("siteDetails").siteName#</cfoutput> > > > > > > in coldspring.xml > > > <bean id="siteDetails" > > > class="ModelGlue.Bean.CommonBeans.SimpleConfig"> > > > <property name="config"> > > > <map> > > > <entry key="favicon"><value> favicon.ico</value></entry> > > > <entry > > > key="siteName"><value>MySite</value></entry> > > > <entry > > > key="siteStyleSheet"><value>/css/v3/eurstart.css</value></entry> > > > </map> > > > </property> > > > </bean> > > > > > > The object isn't showing up when I dump this either. > > > <cfdump var="#viewstate.getAll()#" label="viewstate.getAll()"> > > > <cfdump var="#viewcollection#" label="viewcollection"> > > > > > > > > > > > > > > > --^---------------------------------------------------------------- This email was sent to: lists@... EASY UNSUBSCRIBE click here: http://topica.com/u/?b1drHn.bSZygJ.bGlzdHNA Or send an email to: modelglue-unsubscribe@... For Topica's complete suite of email marketing solutions visit: http://www.topica.com/?p=TEXFOOTER --^---------------------------------------------------------------- |
|
|
Re: Global Application NameThanks very much for your help! My final solution was an adaptation of what Richard did.
In my Coldspring.xml I have this... <bean id="ApplicationConfig" class="ModelGlue.Bean.CommonBeans.SimpleConfig "> <property name="config"> <map> <entry key="shortDisplayName"><value>AppManager</value></entry> <entry key="longDisplayName"><value>Application Manager</value></entry> </map> </property> </bean> In my controller I have this <cffunction name="onQueueComplete" access="public" returnType="void" output="false"> <cfargument name="event" type="any"> <cfset arguments.event.setValue("applicationConfig",getApplicationConfig().getConfig()) /> </cffunction> So that I can reference them in my view like this <cfset appTitle = viewState.getValue("applicationConfig").longDisplayName /> |
| Free Forum Powered by Nabble | Forum Help |