I'm new to Railo, moving away from ColdFusion 8 where my site used to used to use cfx_imagecr3.
I believe Railo has ImageScaleToFit but I'm not sure if I'm using it correctly or if I need to add some kind of class/component? I've added it between a cfscript but i get 'invalid variable declaration' which doest make any sense to me. Any help appreciated.
I'm running railo-4.0.0.013 on ubuntu 12.04
<cfscript>
imageScaletoFit('/home/images/testimage.jpg','90','114','highestPerformance');
</cfscript>
You need to first load the image into a variable, then use that variable name inside ImageScaletoFit, like so:
<cfimage name="ImgVariable" source="/home/images/testimage.jpg" />
<cfset imageScaletoFit(ImgVariable,'90','114','highestPerformance') />
(This isn't specific to Railo - the function exists and works the same way in CF8+)
Related
Tried cy.get(#Username) , doesn't work- cypress says it can't find it. could it be related to uppercase letter?
Installed Xpath plugin and used this
cy.xpath('//input[#id="Username"]') but it didn't work.
<input type="email" class="form-control" autocomplete="off" data-gd="identity-login-local-form-username" autofocus="" data-val="true" data-val-required="The Username field is required." id="Username" name="Username" value="">
Please before giving -1 , please explain what I need to improve. Thanks!
After downloading xpath plugin, did you add require('cypress-xpath') in your project's cypress/support/index.js file?
According to your example, code below should find the Username
cy.xpath('//input[#id="Username"]')
cy.get('#Username')
The capital letter may be causing the problem. Usually ids have a small letter.
Try using the data-gd attribute instead.
cy.get('[data-gy="identity-login-local-form-username"]')
If that does not work, you may have some shadow DOM before the <input> that blocks the search, in which case you can search inside the shadow like this
it('tests the input', {includeShadowDom:true}, () => {
cy.get('[data-gy="identity-login-local-form-username"]')
})
I tested with a capital letter cy.get('#Username') and cy.xpath('//input[#id="Username"]') - both worked for me, so likely there is shadow DOM or an <iframe> on your page.
Is it possible that the page has a default namespace? If the page is served as XHTML, it may have a default XML namespace, in which case the input's name is not simply input.
If that is the problem, then you could declare the http://www.w3.org/1999/xhtml namespace and associate it with a prefix, e.g. xhtml (I don't know cypress so not sure how you'd do that), and then query for //xhtml:input[#id="Username"]. An alternative is to query for an element whose local name is input in any namespace at all, e.g. //*[local-name()='input'][#id="Username"]
In case your username field is under a shadow DOM which means other fields will also be under the shadow Dom, it would be advisable to write includeShadowDom: true in your cypress config file to avoid repetition(cypress.json if cypress version < 10; cypress.config.js if cypress version > 10), then directly use the command:
cy.get('#Username').type('username-text')
In case your username field is under an iframe, you can get the cypress iframe plugin
To install npm install -D cypress-iframe
Go to cypress/support/commands.js file, add the following:
import 'cypress-iframe';
// or
require('cypress-iframe');
In your test write:
cy.iframe('#my-frame')
.find('#Username')
.should('be.visible')
.type('username-text')
I can also confirm the way you are selecting the Username input element is correct.
If you suspect shadow DOM is interfering with your test, the best way to debug IMO is to
inspect your DOM around the <input>
look for a parent element that has #shadow-root below it (in bold)
change the test to include this parent
add the .shadow() command after the parent to break through the barrier
cy.get('parent-with-shadow-root')
.shadow()
.find('#Username')
This debugs and confirms your issue. Everything else, e.g setting global config etc can be done after you know what you have to deal with.
After I tried suggestions and people's confirmation that my xpath was correct, I shifted my focus on the error I got while Cypress was trying to find the element. The error I got was uncaught exception.https://stackoverflow.com/questions/53845493/cypress-uncaught-assertion-error-despite-cy-onuncaughtexception
This error occurs when a module fails to load due to some exception. The error message above should provide additional context. A common reason why the module fails to load is that you've forgotten to include the file with the defined module or that the file couldn't be loaded.
Using ngRoute In AngularJS 1.2.0 and later, ngRoute has been moved to its own module. If you are getting this error after upgrading to 1.2.x or later, be sure that you've installed ngRoute.
Getting this Error
ELEMENT CURRLANGUAGE IS UNDEFINED IN SESSION.
Don't understand why. It was working fine until yesterday
<cfif session.currLanguage eq 'English'>
<cfset session.currLanguage = ''>
</cfif>
Because currLanguage is not defined in the session scope. Womp Womp.
Try this to see what IS defined.
<cfdump var="#SESSION#">
It could be that something is not being set when it should. We'd have to see your code to tell for sure. If you think it's working okay and want to prevent unnecessary error messages in the future, you can do a check like this:
<cfif structKeyExists(SESSION, "currLanguage") AND SESSION.currLanguage is "English">
Logic Logic Logic
</cfif>
Please confirm those too
Please check the value update in the session scope properly.
The session scope will be created based on application name. so if we created the application name as dynamic or updated recently then the session scope will be created as new
I'm trying to create a basic proxy server so I can keep track of what my kids are doing web wise - I know there are products out there but I thought it would be an interesting exercise to write one myself.
I have the following code that kind of works but doesn't pull any images or css through - I guess because it makes another call to the remote server and gets confused
<cfhttp url="https://www.bbc.co.uk">
<cfhttpparam type="header" name="Proxy-Connection" value="keep-alive" >
<cfhttpparam type="header" name="Accept" value="application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5">
<cfhttpparam type="header" name="Accept-Language" value="en-US,en;q=0.8">
<cfhttpparam type="header" name="Accept-Charset" value="ISO-8859-1,utf-8;q=0.7,*;q=0.3">
</cfhttp>
<cfset html = cfhttp.FileContent />
<cfoutput>#html#</cfoutput>`
What am I missing?
What you want to use is the resolveurl parameter of - set it to yes/true. This defaults to no.
What this parameter does is resolves relative paths to absolute paths automatically for you.
Now, if you want to change those paths as well, you would change them to also route through your http proxy script, but there won't be much use as you won't know much about the content regardless.
resolveurl should hook you up with what you are looking for. cheers.
https://cfdocs.org/cfhttp (look for resolveurl tag attribute)
For some reason that I don't understand, on my development machine can't call to function of a cfc component from a cfajaxproxy.
In my cfm document:
<cfajaxproxy cfc="#Application.CfcPath#.empleado"
jsclassname="ccEmpleado">
This works, and also I can instantiate an object to get all the functions of that cfc component:
var cfcEmpleado = new ccEmpleado();
But, when I try to call a function of that object:
var nb_Empleado = cfcEmpleado.RSEmpeladoNombreBIND(1,1);
Debug complains:
Error: The ID_EMPRESA parameter to the RSEmpeladoNombreBIND function is required but was not passed in.
I got this from Network tab on Chrome and figured out that something is generating an invalid parameter:
http://127.0.0.1/vpa/componentes/empleado.cfc?method=RSEmpeladoNombreBIND&_cf_ajaxproxytoken=[object%20Object]&returnFormat=json&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=41C92098C98042112AE2B3AAF523F289&_cf_rc=0
As you can see, there's a parameter [object%20Object], that is messing around my request, and that's why it fails. I don't why is happening this. Other people has tested this, and it works, but in mine doesn't.
I have Coldfusion 9, Apache, Windows 8. Is is some configuration issue on Coldfusion, or a bug?
I can't tell if this is your error or not, but it might be. This was a problem that we had for awhile. You should consider using explicit names to avoid any confusion. Add the "js" in there.
<cfajaxproxy cfc="cfcEmpleado" jsclassname="proxyEmpleado">
var jsEmpleado = new proxyEmpleado();
I will try to find a link to an article about this very thing.
I've been blind sided by the change from CF8 to 9 where write to disk caching is no longer possible without creating a custom cache or some other drastic workarounds that are not worth the effort.
At this time I've abandoned trying to convert the application to uphold, if possible, the same method of writing the contents of a cache file into a static cfm file. I'm more curious now that I've dug into it a bit deeper. I'm looking for someone that has more experience with this than myself.
What I'd like to understand or know how to do with template cache is:
Be able to target a template in default or custom cache and flush it without clearing the entire cache.
View or parse the contents of a particular cached template either out of curiosity or debug approach.
This was the code I was tooling with, requires CF 9.0.1 due to some cache memory functions that are not available in 9.0 due to the addition of EhCache 2.0 I believe.
<cftry>
<cfcache action='serverCache' timeout='#CreateTimeSpan(0,0,0,10)#' stripwhitespace='true'
usequerystring='true'>
Stuff to cache.
<br/>
<cfoutput>#now()#</cfoutput>
<br/>
</cfcache>
<!--- Get the cached contents --->
<cfdump var="#cacheGetProperties()#">
<cfdump var="#getAllTemplateCacheIds()#">
<!---Locate a single cached item --->
<cfscript>
cacheArray = getAllTemplateCacheIds();
WriteOutput("Before<br/>");
for(i=1;i LTE ArrayLen(cacheArray);i=i+1)
{
writeOutput(cacheArray[i] & "<br/>");
if(FindNoCase(scriptPath, cacheArray[i]))
{
//expect only to find min and max one per string so no need to worry about out of bounds
cacheIDSubStr = REFind("[a-fA-F\d]{32}(?=_LINE:\d*$)",cacheArray[i],1,1);
cacheID = Mid(cacheArray[i],CacheIDSubStr.pos[1],CacheIDSubStr.len[1]);
//Failure to delete cache expected fireworks
//WriteOutput(cacheID&"<br/>");
//cacheObject = CacheGet(cacheID);
//CacheRemove(cacheID);
templateCache = cacheGetSession("template");
//Tooling around with the exposed guts of cacheGetSession
WriteDump(templateCache.getKeys());
}
}
</cfscript>
<cfcatch type="Any">
<cfscript>
writeoutput("Error:" & cfcatch.message);
</cfscript>
</cfcatch>
</cftry>
No errors should exist, but it was edited from the original to post here.
The secret is in the CF 9.0.1 function cacheGetSession(), along with the amending of the other functions to take a key as a parameter.
The following code will only work in 9.0.1.
Assuming:
<cfcache action="serverCache" timeout="#CreateTimeSpan(0,0,0,10)#" stripwhitespace="true" usequerystring="true">
Stuff to cache in the default store.
<br/>
<cfoutput>#Now()#</cfoutput>
</cfcache>
<cfcache action="serverCache" key="myCustomCache" timeout="#CreateTimeSpan(0,0,0,10)#" stripwhitespace="true" usequerystring="true">
Stuff to cache in the 'myCustomCache' store.
<cfoutput>#Now()#</cfoutput>
</cfcache>
Accessing the identifiers of the cache separately
Default (Template):
<cfdump var=#getAllTemplateCacheIds()#>
myCustomCache:
<cfdump var=#cacheGetSession('myCustomCache',true).getKeys()#>
Reading the data of the custom cache
<cfset keys = cacheGetSession('myCustomCache',true).getKeys() />
<cfcache key="myCustomCache" action="get" name="dataInCache" id="#keys[1]#">
<cfdump var=#dataInCache#>
Flushing the custom cache independently of the default
<cfset cacheRemove(keys[1],true,'myCustomCache')>
Sadly, documentation is not at its best with regards to the functionality that snuck in with 9.0.1. Luckily, the CF userbase is good at digging this stuff out, namely Rob-Brooks Bilson, who has a number of great articles on CF and caching in general.
Couple of caveats you should remember in working with the cache in this fashion:
These calls tie to EhCache under the hood, which is Java, and may return NULLs if you try to access keys that don't exist. Wrap your results in IsNull() to validate.
cacheGetSession() is misleading (as Rob points out on his blog), you may think you are retrieving session-related cache data as it applies to your app, but that is not the case--it is server-wide, and you will see other cache's keys in a share app environment.
So, take care to flush the appropriate data...