view-page anotherModule:awesomeView

32 views
Skip to first unread message

Miguel Ulloa

unread,
Oct 16, 2013, 4:42:55 PM10/16/13
to mach-ii-for...@googlegroups.com
Hello,

I have a whole bunch of tabs each one is a separate page, say Page1, Page2, and Page 3. I have to create a report that puts them all together so that the client can print them. For each of this pages I have code like this:

<event-handler event="Event1" access="public">
<notify listener="Listener1" method="getPageOneData"  resultKey="request.PageOneData"/>
<view-page name="Page1" contentKey="request.Page1"/>
</event-handler>
<event-handler event="Event2" access="public">
...

so I just defined a separate event-handler to put them all together 

<event-handler event="Report" access="public">
<notify listener="Listener1" method="getPageOneData"  resultKey="request.PageOneData"/>
<view-page name="Page1" contentKey="request.Page1"/>
<notify listener="Listener2" method="getPageTwoData"  resultKey="request.PageTwoData"/>
<view-page name="Page2" contentKey="request.Page2"/>
...
<view-page name="PrintReport"/>
</event-handler>

My PrintReport view looks something like this:

#request.Page1#<br>#request.Page2#<br>#request.Page3#

This works fine, but now for say page 4, the event-handler is defined in another module, say MODULE2. The listener is defined on the current module so it is accessible, but the view is not. Is it possible to save the content of the view "MODULE2:Page4" as follows? Well i tried alreayd it did not work, I am guessing I could simply define the view in the current module, but i am not sure I may run into other issues. Can you please suggest any solutions?

<event-handler event="Report" access="public">
<notify listener="Listener1" method="getPageOneData"  resultKey="request.PageOneData"/>
<view-page name="Page1" contentKey="request.Page1"/>
<notify listener="Listener2" method="getPageTwoData"  resultKey="request.PageTwoData"/>
<view-page name="Page2" contentKey="request.Page2"/>
...
<notify listener="Listener4" method="getPageTwoData"  resultKey="request.PageTwoData"/>
<view-page name="MODULE2:Page4" contentKey="request.Page4"/>

<view-page name="PrintReport"/>
</event-handler>

Thanks in advance,
-Miguel

Miguel Ulloa

unread,
Oct 17, 2013, 8:57:57 AM10/17/13
to mach-ii-for...@googlegroups.com
UPDATE: I looked through the documentation, I did not see a way to access views from another module within the same app. I ended up redefining the MODULE:view on my current configuration. That worked.
...
<notify listener="Listener4" method="getPageTwoData"  resultKey="request.PageTwoData"/>
<view-page name="Page4" contentKey="request.Page4"/>

<view-page name="PrintReport"/>
</event-handler>
...
<page-view name="Page4" page="/pathTo/Page4.cfm" />

Will Young

unread,
Oct 18, 2013, 7:52:16 AM10/18/13
to mach-ii-for...@googlegroups.com
Hi MIguel,

If your wanting to use a view within multiple modules then you can define that view within the master "mach-ii.xml" files and then call it within multiple modules..

e.g.
within mach-ii.xml:

<page-views>
    <view-page name="MasterTemplate" page="/template.cfm" />
</page-views>

and then just call it as you would normally within the individual modules?

I think this should do the trick if i've understood your original request correctly?

Regards,
Will

Brian Klaas

unread,
Oct 18, 2013, 8:21:30 AM10/18/13
to mach-ii-for...@googlegroups.com
As you discovered, you can't reference views in one module from another module. Modules are really meant to be standalone, isolated chunks of functionality. You can inherit certain properties from the base Mach-II app to a module (plugins, filters, and objects defined in a base ColdSpring configuration, for example), but anything defined inside a module can't be accessed by the parent or another module.

brian

Miguel Ulloa

unread,
Oct 18, 2013, 1:42:22 PM10/18/13
to mach-ii-for...@googlegroups.com
Hello Will/Brian,

That makes perfect sense. From a design stand point at the point at which a object is needed across more than one module, it needs to be defined in the base machii configuration. I have moved my definition there.

thanks,
-Miguel

drfishflan

unread,
Nov 27, 2013, 5:40:07 AM11/27/13
to mach-ii-for...@googlegroups.com
Hi Guys

drfishflan

unread,
Nov 27, 2013, 5:46:19 AM11/27/13
to mach-ii-for...@googlegroups.com
I would say that you have pros and cons to consider hear.

You could define your view in the parent machii.xml config... And this will propagate to the child modules.

The problem with this is that your modules are now not completely abstracted.

I personally would define the views within each modules config... this stops the problem of unclear dependencies on the core machii config xml.

Although this creates repetition I see no problem with this... and there is no performance impact.

However... with Listeners we cannot do this.. since for each module a new Listener is instantiated.... So with Listeners I would define them in my parent machii config xml... but put clear comments in my modules xml point out that these dependencies exists.

Its a shame that machii cannto "detect" that a listener is already loaded in another module and not load it again..

Please feel free to correct me on any of this

thanks!

Peter J. Farrell

unread,
Nov 27, 2013, 6:02:55 AM11/27/13
to mach-ii-for...@googlegroups.com
drfishflan said the following on 11/27/2013 04:46 AM:
>
>
> Its a shame that machii cannto "detect" that a listener is already
> loaded in another module and not load it again..
>
Considering that listeners can pull in different configuration upon
instantiation of the object, it would be less than desirable of behavior
to use an in memory cached version from somewhere else. Its too
difficult to know if the internal state of an object is the same and
therefore you could have unintended behavior. If you're listeners are
init'ing many components -- I would look at ColdSpring 1.x branch to
wire in dependencies.

--
Peter J. Farrell
OpenBD Steering Committee / Mach-II Lead Developer
http://blog.maestropublishing.com
Identi.ca / Twitter: @maestrofjp

Please do not send me Microsoft Office/Apple iWork documents. Send OpenDocument instead! http://fsf.org/campaigns/opendocument/

drfishflan

unread,
Nov 27, 2013, 6:08:35 AM11/27/13
to mach-ii-for...@googlegroups.com
Thanks very much for this Peter!

I can see what you are saying... In our implementation I see now way of adjusting the configuration of a listener depending on the module it is loaded from.

Just being curious how you would be able to do this.

Thanks again for your response.... good to learn from those who know!

:)
Reply all
Reply to author
Forward
0 new messages