Teaman said the following on 06/04/2009 06:04 PM:
> Well, what I detailed doesn't work. I'm missing something.
> There appears to be one or two problems.
> 1. The ViewHelper (I ended up changing the name to be this instead of
> ViewFormatter) init requires the DSN to be passed in as an argument.
> I don't know how to do that using setProperty. I tried two different
> approaches but neither worked.
> a. <cfset setProperty('viewHelper', views.ViewHelper)> doesn't handle
> arguments.
> b. so then I tried to specify the component as a type in the mach-
> ii.xml properties section:
> <property name="viewHelper" type="views.ViewHelper" />
> While the mach-ii.xml allows passing in parameters, it doesn't allow
> passing arguments that I'm aware of, or are they the same thing? If
> so, it didn't work:
> <property name="viewHelper" type="views.ViewHelper">
> <parameters>
> <parameter name="dsn" value="#Application.DSN#"
> />
> </parameters>
> </property>
>
> 2. In my view file, I have this call:
> <cfset webroot = getProperty('viewHelper').getWebRoot(CGI.SERVER_NAME,
> qDocsList.language)>
> but I get the error stating that getWebRoot method is not defined.
> It's as if the ViewHelper.cfc component isn't getting instantiated.
> Is this a syntax issue?
>
> I guess my gut says I should be using the more common instantiation
> method instead:
> <cfset viewHelper = createObject("component", "views.ViewHelper").init
> ( DSN = APPLICATION.dsn ) />
> but where would that go?
> I was just trying to go with your suggestion to use the setProperties
> approach.
>
> What am I missing here in my understanding?
>
The documentation states that any Mach-II extended component does not
have an init() method (the framework takes care of that for you). Any
instantiation like logic should be placed in your configure() method
where you can then access the parameter you defined in your XML.
https://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/NewPropertyDatatypes#MachII.framework.PropertyCFC
You don't have to do any setProperty() stuff anywhere if you define your
property.cfc in the XML. The framework auto-loads it for you.
The reason why it's not working is that you are overriding the init()
method that the BaseComponent has already and therefore breaking how the
framework instantiates the controller level components for you.
You should define your DSN as a Mach-II property (which "acts" like an
application scope) instead of directly putting it in the application
scope itself). If it varies based on where your application is
deployed, look at the EnvironmentProperty which takes care of setting up
environment specific properties based on the deployment location of your
application.
HTH,
.pjf
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to Mach-II for CFML list.
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/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets:
http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
-~----------~----~----~----~------~----~------~--~---