viewlet widget

I’m having issues passing args to the viewlet widget. Does anyone have an example?

I’ve tried this
{{{Viewlet:event=‘handler.function’,args=‘myvar:1234’}}}
and this
{{{Viewlet:event=‘handler.function’,args=’{myvar:1234}’}}}
and this

{{{Viewlet:event=‘handler.function’,args=’“myvar”:“1234”’}}}

Can someone give me a simple example?

Thanks.

Jonathan

Pretty sure you need to define your args as a structure

{{{Viewlet:event=‘handler.function’,args=’{myvar=“1234”}’}}}

I’m sure someone will correct me if I’m wrong :wink:

No good. It’s the little things.

Error translating widget: The ARGS argument passed to the renderIt function is not of type struct. If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible.

It should be a JSON structure that is inflated later. I will try this and report back. Can you post an example here please.

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

{{{Viewlet:event=‘handler.function’,args=’{myvar=“1234”}’}}}

Ok, bug verified and fixed in the development branch.

I changed it to pass a comma delimited list of name value pairs. Much easier to parse and better looking since you are already in the {{{}}} notations.

{{{Viewlet event=“general.test” args=“myvar=test,name=luis,widget=true”}}}

{{{Renderview view=“contacts” args=“myvar=test,name=luis,widget=true”}}}

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Great thanks for quick response.

I did some testing using the viewlet example and find that value isn’t getting passed. I did a writeoutput(event.getvalue(‘myvar’,‘fail’));abort; and I get fail and not the value of test from args=“myvar=test”.

I even dumped rc and prc and looked and don’t see it. I looked at the widget code and it does create the struct as expected and pass it to the runevent. Any idea why I wouldn’t be abel to see the value?

signature0.jpg

Jonathan,

event argumetns and view arguments do not go into the request collection. Event arguments are passed to the event handler as method arguemnst. In views, arguments are contained in the “args” structure.

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

Thank you very much. Works like a charm.

Help.

I can’t figure out where to place my handler for the viewlet.
{{{Viewlet:event=‘Recipes.form’,private=‘false’}}}

outputs “not valid registered event.”

Where do I save my Recipes.cfc?

Just like a normal ColdBox app in your handlers folder.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Thanks. Just like Jonathan said, works like a charm.

/contentbox
/contentbox-admin
/contentbox-ui
/recipes
  + handlers
    + main.cfc
  + views
    + index.cfm

How do I call my recipes module main handler using the viewlet widget?

This doesnt work:
{{{Viewlet:event=‘recipes:main.form’}}}

There was a typo on my ModuleConfig.cfc, but while reloading application it throws# coldfusion.runtime.EventHandlerException: Event handler exception.

I should be able run other modules alongside contentbox modules. If I remove my module app runs ok. Once I add it back in it throws the same error:

coldfusion.runtime.CustomException: coldfusion.runtime.EventHandlerException: Event handler exception.
	at coldfusion.tagext.lang.ThrowTag.doStartTag(ThrowTag.java:142)
	at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)
	at cfApplication2ecfc500155455$funcONERROR.runFunction(D:\Websites\test.wholefrev.com\Application.cfc:134)
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
	at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
	at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
	at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
	at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
	at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:491)
	at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337)
	at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:88)
	at coldfusion.runtime.AppEventInvoker.onError(AppEventInvoker.java:427)
	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:425)
	at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
	at coldfusion.filter.PathFilter.invoke(PathFilter.java:94)
	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
	at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
	at coldfusion.CfmServlet.service(CfmServlet.java:200)
	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
	at com.intergral.fusionreactor.filter.FusionReactorCoreFilter.doRequestNoFilter(FusionReactorCoreFilter.java:712)
	at com.intergral.fusionreactor.filter.FusionReactorCoreFilter.doFusionRequest(FusionReactorCoreFilter.java:341)
	at com.intergral.fusionreactor.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:246)
	at com.intergral.fusionreactor.filter.FusionReactorFilter.doFilter(FusionReactorFilter.java:121)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
	at com.seefusion.Filter.doFilter(Filter.java:49)
	at com.seefusion.SeeFusion.doFilter(SeeFusion.java:1500)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
	at jrun.servlet.FilterChain.service(FilterChain.java:101)
	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
	at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Ok, I configured my module correctly and it works ok now. I was missing the routes structure in my moduleconfig.cfc.

But I can’t seem to figure out how to call my module event from a contentbox page using {{{Viewlet:event=“recipes:recipes.main”}}}

Using {{{Viewlet:event=“recipes:recipes.main”}}}

errors: Error executing viewlet: recipes:recipes.main(). The event: recipes:recipes.main is not valid registered event.

Execute it normally and see if it works.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

I see now that the renderView widget has the option to set the module. I suppose I can runEvent my module from the view.

Does the viewLet widget support module events?

Luis,

It didn’t work then it occured to me that I can’t have two modules with the same name.
modules/contentbox/modules/recipes
modules/recipes

I renamed one to recipes-admin and it works now. Thank you.