I must use a condition like this in my Javascript code
if (condition) statement;
but it returns an error
(" Expected '{' and instead saw ' '. ")
while validating using jslint4java. Is there is any way to skip this checking?
I don't think so. The way to find out is to visit jslint.com and see what option you can use, then pass that option to jslint4java. But I've just checked and none of the options appear to do what you want.
Related
While including JIRA issues Macro on my Wikipage, I am having this issue.
On Jira, for a list of tickets, I have put the the Fix Version = 6.0.0-beta3+ha1 .
By doing so whenever I try to add JIRA Issue, with the following url
http://rdtrack/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=fixVersion+%3D+6.0.0-beta3+ha1&tempMax=1000
I get this message.
The JIRA Issue was not able to process the search. This may indicate a problem with the syntax of this macro.....
What is my understanding is that symbol "+" in 6.0.0-beta3+ha1 is causing this issue. I search on the Internet and found that using special characters like "+, etc.", they should be used within '' or " ". Still using them does solve my issue and I cannot see the list of JIRA tickets using URL mentioned above.
Escape the + as it's a reserved character and remove the unnecessary one from your query.
jqlQuery=fixVersion%3D6.0.0-beta3%2Dha1&tempMax=1000
Building on #rorschach's answer, try the following, which wraps quotes around the fixversion value (which is what you alluded to in your question).
jqlQuery=fixVersion%3D%226.0.0-beta3%2Dha1%22&tempMax=1000
Also, for a little bit more clarification on the +:
In JIRA, it does need wrapping in quotes... and in the URL, it's generally translated to a space. That's why you need to escape the + in the URL, but still quote the escaped fixversion value.
I tried the following code:
page.execute_script " $('#{selector}').trigger('mouseenter').click();"
I can't use use jquery with capybara. (unknown error (Selenium::WebDriver::Error::JavascriptError))
Can someone suggest to me what I am missing?
I am using capybara (1.1.2), selenium-webdriver(2.29)
You can't have double quotation marks in strings unless you escape them. In this scenario though, that can get messy rather quickly. Try this
page.execute_script("$('#{selector}').trigger('mouseenter').click();")
I need to parse and replace text using gsub and a regular expression. A simplified example appears below where I'm saving one of the captured groups -- \3 -- for use in my replacement string.
my_map.gsub(/(\shref=)(\")(\d+), ' href="/created_path/' + '\3' + '" ' + ' title="' + AnotherObject.find('\3')'"')
In the first use of the captured value, I'm simply displaying it to build the new path. In the second example, I am calling a find with the captured value. The second example will not work.
I've tried various ways of escaping the value ("\3", ''\3'', etc) and even built a method to test displaying the value (works) or using the value in a method (doesn't work).
Any advice is appreciated.
Use the block form of gsub and replace your \3 references with $3 globals:
my_map.gsub(/(\shref=)(\")(\d+)/) { %Q{ href="/created_path/#{$3}" title="#{AnotherObject.find($3)"} }
I also switched to %Q{} for quoting to avoid the confusing quote mixing and concatenation.
The second argument in the replacement-string form of gsub (i.e. the version of gsub that you're trying to use) will be evaluated and concatenated before gsub is called and **before **the \3 value is available so it won't work.
As an aside, is there a method you should be calling on what AnotherObject.find($3) returns?
I have two <p:dailog>s and based on the condition of a bean property I want to show one of them. I have used the following code
onclick="#{empty groupBean.selectionGroup?dialog_empty.show():groupDialog.show()}"
But it is not working as it says there is an error in EL expression. I am not sure where the error is. Am I doing it the correct way?
You're treating JavaScript code as part of the EL expression. This would only result in a syntax error because EL cannot find #{dialog_empty} nor #{groupDialog} in the scope. You have to treat JavaScript code as strings by quoting them because they ultimately needs to be written to the HTML response as-is:
onclick="#{empty groupBean.selectionGroup ? 'dialog_empty.show()' : 'groupDialog.show()'}"
I'm trying to store regexes in a database but they're not working when used in a .sub(), even though the same regex works when used directly in .sub() as a string.
regex = Class.object.field // Class.object is an active record containing "\w*\s\/\s"
mystring = "first / second"
mystring.sub(/#{regex}/, '')
// => nil
mystring.sub(/\w*\s\/\s/, '')
// => second
Any insight appreciated!
Thanks,
Matt.
Editing to correct class/object terminology (thanks) & correcting my 2nd example as I had shown #{} wrapped around the working regex (cut & paste SNAFU).
To answer your question: It is not quite what kind of thing your Class.object is. If it's an ActiveRecord, it won't work.
Edit: You obviously found that the problem is Rails escaping the regexp.
An ActiveRecord cannot "contain" your regular expression directly; the regexp will be in one of the fields of your record. In which case you'd want to do something like regexp = Class.object.field_containing_the_regexp.
Even if that is not the case, I suspect that the problem is that your regexp is something other than a string. You can quickly test this by using
puts "My regexp: #{regexp}"
The string that you will see in the output will be the one that is used for the regexp.
A String is not a Regexp. You have to create a Regexp object first.
regex = Regexp.new("\w*\s\/\s")
Turns out my regexp didn't cater for all cases - \w didn't account for symbols. After checking in rails console, and seeing the screwey escaping I was alreasdy half-way down the wrong track.
Thanks for the help.