http://bugs.farcrycms.org/browse/FC-1999
Is anyone using AJAX webskins? Please vote for this is you think it will be useful. 2009/10/21 Blair McKenzie <[email protected]> > Could work. Add a ticket. We'll have to get Matt (the mastermind behind > this feature) to have a look at it. > > Blair > > > On Wed, Oct 21, 2009 at 5:14 PM, AJ Mercer <[email protected]> wrote: > >> Hi Blair, >> >> Here is some hacked code out of fourq.cfc (5.2.something not necessarily >> current) >> that appends stParam attributes to the URL passed to ajax function >> (search for AJM for hacks) >> >> Thoughts / Comments >> >> >> >> <cffunction name="getView" access="public" output="true" >> returntype="string" hint="Returns the HTML of a view from the webskin >> content type folder."> >> <cfargument name="objectid" required="no" type="string" default="" >> hint="ObjectID of the object that is to be rendered by the webskin view." /> >> <cfargument name="template" required="no" type="string" default="" >> hint="Name of the template in the corresponding content type webskin folder, >> without the .cfm extension." /> >> <cfargument name="webskin" required="no" type="string" default="" >> hint="Name of the template in the corresponding content type webskin folder, >> without the .cfm extension." /> >> <cfargument name="stparam" required="false" type="struct" >> default="#structNew()#" hint="Structure of parameters to be passed into the >> display handler." /> >> <cfargument name="stobject" required="no" type="struct" >> hint="Property structure to render in view. Overrides any property >> structure mapped to arguments.objectid. Useful if you want to render a view >> with a modified content item."> >> <cfargument name="dsn" required="no" type="string" >> default="#application.dsn#"> >> <cfargument name="OnExit" required="no" type="any" default=""> >> <cfargument name="alternateHTML" required="no" type="string" >> hint="If the webskin template does not exist, if this argument is sent in, >> its value will be passed back as the result."> >> <cfargument name="hashKey" required="no" default="" type="string" >> hint="Pass in a key to be used to hash the objectBroker webskin cache"> >> <cfargument name="bAjax" required="no" default="0" type="boolean" >> hint="Flag to determine whether to render an ajax call to load the webskin >> instead of inline." /> >> <cfargument name="ajaxID" required="no" default="" type="string" >> hint="The id to give the div that will call the ajaxed webskin" /> >> <cfargument name="ajaxShowloadIndicator" required="no" >> default="false" type="boolean" hint="Should the ajax loading indicator be >> shown" /> >> <cfargument name="ajaxindicatorText" required="no" >> default="loading..." type="string" hint="What should be text of the loading >> indicator" /> >> <cfargument name="bIgnoreSecurity" required="false" type="boolean" >> default="false" hint="Should the getView() ignore webskin security" /> >> <cfargument name="bAllowTrace" required="false" type="boolean" >> default="true" hint="Sometimes having webskin trace information can break >> the integrity of a page. This allows you to turn it off." /> >> >> <cfset var stResult = structNew() /> >> <cfset var stObj = StructNew() /> >> <cfset var WebskinPath = "" /> >> <cfset var stWebskin = structNew() /> >> <cfset var stCurrentView = structNew() /> >> <cfset var stArgs = structnew() /> >> <cfset var i = 0 /> >> <cfset var stLocal = structNew() /><!--- A local scope that can be >> used in webskins to ensure against race conditions. ---> >> <cfset var webskinTypename = "" /><!--- This will store the >> typename of the webskin to be called. Required in the case of Type Webskins. >> ---> >> <cfset var iViewState = "" /><!--- iterator used when adding to >> ancestor cacheBySessionVar lists ---> >> <cfset var lAttributes = >> "stobject,typename,objectid,key,template,webskin,stprops,stparam,r_html,r_objectid,hashKey,alternateHTML,OnExit,dsn,bAjax,ajaxID,ajaxShowloadIndicator,ajaxindicatorText,bIgnoreSecurity" >> /> >> <cfset var attrib = "" /> >> <cfset var lHashKeys = "" /> >> <cfset var iHashKey = "" /> >> <cfset var urlParameters = "" /> <!--- AJM ---> >> >> <cfimport taglib="/farcry/core/tags/extjs" prefix="extjs" /> >> <cfimport taglib="/farcry/core/tags/webskin" prefix="skin" /> >> <cfimport taglib="/farcry/core/tags/farcry" prefix="farcry" /> >> >> <!--- Initialise webskin trace array ---> >> <cfparam name="request.aAncestorWebskinsTrace" >> default="#arrayNew(1)#" /><!--- To Be Used for Trace Tree ---> >> >> <!--- init fourq ---> >> <cfset fourqInit() /> >> <cfset webskinTypename = "#variables.typename#" /><!--- Set the >> typename to the typename of this object instance ---> >> >> >> <cfif len(arguments.webskin)> >> <cfset arguments.template = arguments.webskin /> >> <cfelseif not len(arguments.template)> >> <cfthrow message="The getView function requires the template >> or webskin argument."> >> </cfif> >> >> <!--- make sure that .cfm isn't passed to this method in the >> template argument ---> >> <cfif listLast(arguments.template,".") EQ "cfm"> >> <cfset arguments.template = >> ReplaceNoCase(arguments.template,".cfm", "", "all") /> >> </cfif> >> >> <cftimer label="view: #webskinTypename# #arguments.template#"> >> <cfif isDefined("arguments.stobject") and not >> structIsEmpty(arguments.stObject)> >> <cfset stobj=arguments.stobject /> >> <cfelse> >> <cfif not len(arguments.objectid)> >> <!--- >> WE WANT TO CALL A TYPE WEBSKIN >> THIS MEANS THAT THE OBJECT THAT WE ARE PASSING TO THE >> WEBSKIN IS ACTUALLY THE farCOAPI object. >> THE WEBSKIN CACHING IS ALSO DONE AGAINST THE farCOAPI >> object. >> ---> >> <cfset stObj = >> application.fc.factory['farCoapi'].getCoapiObject(name="#webskinTypename#") >> /> >> >> <cfelse> >> <!--- get the data for this instance ---> >> <cfset stObj = >> getData(objectid=arguments.objectID,dsn=arguments.dsn)> >> </cfif> >> >> >> </cfif> >> >> <cfif arguments.bAjax> >> <cfif not len(arguments.ajaxID)> >> <cfset arguments.ajaxID = >> "#stobj.typename#_#stobj.objectid#_#arguments.template#" /> >> </cfif> >> <skin:htmlHead library="extjsCore" /> >> <skin:htmlHead id="webskinAjaxLoader"> >> <cfoutput> >> <script type="text/javascript"> >> function >> webskinAjaxLoader(divID,action,timeout,showLoadIndicator,indicatorText){ >> if (timeout == undefined){var timeout = 30}; >> if (showLoadIndicator == undefined){var showLoadIndicator >> = false}; >> if (indicatorText == undefined){var indicatorText = >> 'loading...'}; >> >> var el = Ext.get(divID); >> >> if(el) { >> var mgr = el.getUpdater(); >> >> mgr.showLoadIndicator = showLoadIndicator; >> if (showLoadIndicator==true){ >> mgr.indicatorText = indicatorText; >> } >> mgr.update( >> { >> url: action, >> nocache: true, >> scripts: true, >> timeout: timeout >> }); >> } >> } >> </script> >> </cfoutput> >> </skin:htmlHead> >> >> <!--- Get the url for the ajax webskin loader ---> >> <!--- AJM: add stParams to URL ---> >> <cfset urlParameters="view=#arguments.template#&ajaxmode=1" /> >> <!--- Setup custom attributes passed into getView in >> stParam structure ---> >> <cfif not structIsEmpty(arguments.stParam)> >> <cfset lHashKeys = >> listSort(structKeyList(arguments.stParam),"text", "asc") /> >> <cfloop list="#lHashKeys#" index="iHashKey"> >> <cfif IsSimpleValue(arguments.stParam[iHashKey])> >> <cfset urlParameters = >> "#urlParameters#&#iHashKey#=#arguments.stParam[iHashKey]#" /> >> <cfelse> >> <!--- dunno?? ---> >> </cfif> >> </cfloop> >> </cfif> >> <cfset urlAjaxLoader = >> application.fapi.getLink(type="#stobj.typename#", >> objectid="#stobj.objectid#", urlParameters="#urlParameters#") /> >> <!--- /AJM ---> >> >> <!--- AJM <cfset urlAjaxLoader = >> application.fapi.getLink(type="#stobj.typename#", >> objectid="#stobj.objectid#", >> urlParameters="view=#arguments.template#&ajaxmode=1") /> ---> >> >> <cfsavecontent variable="stWebskin.webskinHTML"> >> <cfoutput> >> <farcry:traceWebskin >> objectid="#stobj.objectid#" >> typename="#stobj.typename#" >> template="#arguments.template#"> >> >> <div id="#arguments.ajaxID#"></div> >> >> </farcry:traceWebskin> >> >> <extjs:onReady> >> <cfoutput> >> webskinAjaxLoader('#arguments.ajaxID#', >> '#urlAjaxLoader#', 30, #arguments.ajaxShowLoadIndicator#, >> '#arguments.ajaxIndicatorText#'); >> </cfoutput> >> </extjs:onReady> >> </cfoutput> >> </cfsavecontent> >> <cfelse> >> >> >> >> <!--- Setup custom attributes passed into getView in stParam >> structure ---> >> <cfloop collection="#arguments#" item="attrib"> >> <cfif not listFindNoCase(lAttributes, attrib)> >> <cfset arguments.stParam[attrib] = arguments[attrib] >> /> >> </cfif> >> </cfloop> >> >> <!--- If we are potentially caching this webskin, and we have >> passed in parameters, we need to create a hash key that uniquely identifies >> these parameters and cache agains them ---> >> <cfif application.bObjectBroker AND >> application.stcoapi[webskinTypename].bObjectBroker AND >> len(arguments.template) AND >> structKeyExists(application.stcoapi[webskinTypename].stWebskins, >> arguments.template) AND >> application.stcoapi[webskinTypename].stWebskins[arguments.template].cacheStatus >> EQ 1> >> <cfif not structIsEmpty(arguments.stParam)> >> <cfset lHashKeys = >> listSort(structKeyList(arguments.stParam),"text", "asc") /> >> <cfloop list="#lHashKeys#" index="iHashKey"> >> <cfif IsSimpleValue(arguments.stParam[iHashKey])> >> <cfset arguments.hashKey = >> listAppend(arguments.hashKey, >> "stParam[#iHashKey#]:#arguments.stParam[iHashKey]#") /> >> <cfelse> >> <cfset arguments.hashKey = >> listAppend(arguments.hashKey, "stParam[#iHashKey#]:{complex}") /> >> </cfif> >> </cfloop> >> </cfif> >> </cfif> >> >> >> <!--- Check permissions on this webskin ---> >> <cfif not bIgnoreSecurity> >> <cfif arguments.template eq "deniedaccess" or not >> application.security.checkPermission(type=webskinTypename,webskin=arguments.template)> >> <!--- Make sure this page doesn't get cached ---> >> <cfif structKeyExists(request, "aAncestorWebskins")> >> <cfloop from="1" >> to="#arraylen(request.aAncestorWebskins)#" index="i"> >> <cfset request.aAncestorWebskins[i].okToCache >> = 0 /> >> <cfif structKeyExists(stCurrentView, >> "cacheTimeout")> >> <cfset >> request.aAncestorWebskins[i].cacheTimeout = stCurrentView.cacheTimeout /> >> </cfif> >> </cfloop> >> </cfif> >> >> <cfsavecontent >> variable="stWebskin.webskinHTML"><cfinclude >> template="#getWebskinPath(webskinTypename,'deniedaccess')#" >> /></cfsavecontent> >> <cfreturn stWebskin.webskinHTML /> >> </cfif> >> </cfif> >> >> <cfif NOT structIsEmpty(stObj)> >> <cfset stWebskin = >> application.fc.lib.objectbroker.getWebskin(objectid=stobj.objectid, >> typename=stobj.typename, template=arguments.template, >> hashKey="#arguments.hashKey#") /> >> >> <cfif not len(stWebskin.webskinHTML)> >> >> <cfif stobj.typename EQ "farCoapi"> >> <!--- This means its a type webskin and we need to >> look for the timeout value on the related type. ---> >> <cfset stCoapi = >> application.fc.factory['farCoapi'].getData(objectid="#stobj.objectid#") /> >> <cfset webskinTypename = stCoapi.name /> >> </cfif> >> <cfset webskinPath = >> application.coapi.coapiadmin.getWebskinPath(typename=webskinTypename, >> template=arguments.template) /> >> >> <cfif len(webskinPath)> >> >> <cfset stWebskin.webskinHTML = runView( >> >> stobj="#stobj#", >> >> webskinTypename="#webskinTypename#", >> >> webskinTemplate="#arguments.template#", >> >> webskinPath="#webskinPath#", >> >> webskinCacheID="#stWebskin.webskinCacheID#", >> >> hashKey="#arguments.hashKey#", >> >> stParam="#arguments.stParam#", >> >> OnExit="#arguments.onExit#", >> >> dsn="#arguments.dsn#", >> >> bAllowTrace="#arguments.bAllowTrace#") /> >> >> <cfelseif structKeyExists(arguments, "alternateHTML")> >> <cfset stWebskin.webskinHTML = >> arguments.alternateHTML /> >> <cfelse> >> <cfthrow type="Application" >> message="Error: Template not found >> [/webskin/#webskinTypename#/#arguments.template#.cfm] and no alternate html >> provided." >> detail="Error: Template not found >> [/webskin/#webskinTypename#/#arguments.template#.cfm] and no alternate html >> provided. typename: #stobj.typename#. objectid: #stobj.objectid#." /> >> </cfif> >> </cfif> >> <cfelse> >> <cfthrow type="Application" detail="Error: When trying to >> render [/webskin/#webskinTypename#/#arguments.template#.cfm] the object was >> not created correctly." /> >> </cfif> >> >> <cfif structKeyExists(request, "aAncestorWebskins") AND >> arrayLen(request.aAncestorWebskins)> >> <cfset request.currentViewTypename = >> request.aAncestorWebskins[arrayLen(request.aAncestorWebskins)].typename /> >> <cfset request.currentViewTemplate = >> request.aAncestorWebskins[arrayLen(request.aAncestorWebskins)].template /> >> </cfif> >> >> </cfif> >> >> </cftimer> >> <cfreturn stWebskin.webskinHTML /> >> </cffunction> >> >> >> >> >> >> 2009/10/21 Blair McKenzie <[email protected]> >> >> You can't. bAjax is just a shortcut for a very simple case. If you want to >>> do something more complex you really need to do it yourself. >>> >>> Blair >>> >>> >>> On Wed, Oct 21, 2009 at 4:17 PM, AJ Mercer <[email protected]> wrote: >>> >>>> I have the following code >>>> <skin:view typename="pslClient" template="displayBodyASXNews" >>>> bAjax="false" stProperties="#stObj#" /> >>>> that populates the stParam struct with stProperties >>>> >>>> But where I set bAjax to TRUE it does not get passed in >>>> Which is most likely fair enough can the browser is calling the webskin >>>> directly >>>> >>>> So, how do you go about passing data to an ajax webskin? >>>> >>>> In this instance, it is within a rule execute.cfm >>>> >>>> >>>> Farcry 5.2 >>>> >>>> -- >>>> AJ Mercer >>>> Web Log: http://webonix.net >>>> >>>> >>>> >>> >>> >>> >> >> >> -- >> AJ Mercer >> Web Log: http://webonix.net >> >> >> > > > > -- AJ Mercer Web Log: http://webonix.net --~--~---------~--~----~------------~-------~--~----~ You received this message cos you are subscribed to "farcry-dev" Google group. To post, email: [email protected] To unsubscribe, email: [email protected] For more options: http://groups.google.com/group/farcry-dev -------------------------------- Follow us on Twitter: http://twitter.com/farcry -~----------~----~----~----~------~----~------~--~---
