indexOf for strings not working after struts jquery plugin 3.7.1 upgrade - struts2-jquery

I upgraded struts jquery plugin to 3.7.1 and jquery-ui.js to 1.10.4.
With my previous struts jquery plugin 3.1.1 and jquery-ui.js 1.8.15, indexOf for the strings is working. Dont know where it hit after upgrade. I get the following error.
SCRIPT5007: Unable to get value of the property 'indexOf': object is null or undefined
My code is as below.
var innerSpanId = $(this).attr('id');
var value = innerSpanId.indexOf('accountcheckbox');
Do give in your suggestions?

I was trying to get the index of strings without an object.
In upgraded jquery use the string object.
var innerSpanId = new String($(this).attr('id'));
var value = innerSpanId.indexOf('accountcheckbox');
Works Perfect!!!

Related

h:selectOneMenu doe not work after Myfaces upgradation from 1.1.4 to 1.1.8

Iam using JSF 1 and trying to update Myfaces version from 1.1.4 to 1.1.8
I have something like this in myxhtml page,
<h:selectOneMenu id="orgCountry" value="#{crud.orgAddress.country}
<f:selectItem itemLabel="#{messageResources.dropDownPleaseSelect}" itemValue=""/>
<f:selectItem itemLabel="#{crud.usrbld.countryName}" itemValue="#{crud.usrbld.countryId}"/>
<f:selectItems value="#{getSelectItems('countryDAOCrud')}"/>
<a4j:support id="countryDropDown" event="onchange" ajaxSingle="true" reRender="orgState" oncomplete="updateStateDropdown()"/>
</h:selectOneMenu>
and getselectItems is a normal method,
getselectItems (){
list= gettingfromDB
converting into selectItem type
And country is a normal pojo class with hash and equals method
When Myfaces 1.1.4 is used, everything works fine but when upgraded to Myfaces 1.1.8,
My submit is failing,and that is due to the validation error,which says,
ParametrizableFacesMessage "{0}": Value is not a valid option.
The cause for this error is the matchvalue method in _SelectItemUtil which is,
Object itemValue = item.getValue();
if (value==itemValue || (itemValue.equals(value)))
{
return true;
}
So here the value is the selected value from dropdown and itemValue is one of the items of SelectItem (this is in Iterator Loop), here the value is of my class type and itemValue is string and since they never match validation always fails.
Whereas in Myfaces 1.1.4 the itemValue is converted to class object type and thus the comparison returns success.
I would not be able to upgrade JSF version.
Can anybody please help me in resolving the issue.Thanks in advance.
I had to overwrite the jar method to solve this problem

Type name 'serializeObject' does not exist in the type 'JsonConvert'

I am trying to convert some data to Json to send to the CloudFlare API. I am attempting to use Newtonsoft.Json.JsonConvert.SeriablizeObject() to accomplish this but I am getting the Intellisense error that the type name 'serializeObject' does not exist in the type 'JsonConvert'. I have the NuGet package Newtonsoft.Json installed but it does not recognize the SerializeObject() method. I am not sure what I am missing.
Its because you're calling the method wrong, remove the new operator from the line
var json = new JsonConvert.SerializeObject(updateDnsRecord);
to
var json = JsonConvert.SerializeObject(updateDnsRecord);

Access window object / browser scope from protractor

I'm running tests with protractor, but it seems impossible to access the JS 'window' object. I even tried adding a tag in my html file that would contain something like
var a = window.location;
and then try expect(a) but I couldn't make it work, I always get undefined references...
How should I process to access variables that are in the browser scope ?
Assuming you are using a recent version of Protractor, let's say >= 1.1.0, hopefully >= 1.3.1
Attempting to access Browser side JS code directly from Protractor won't work because Protractor runs in NodeJS and every Browser side code is executed through Selenium JsonWireProtocol.
Without further detail, a working example:
browser.get('https://angularjs.org/');
One-liner promise that, as of today, resolves to '1.3.0-rc.3'
browser.executeScript('return window.angular.version.full;');
You can use it directly in an expect statement given Protractor's expect resolves promises for you:
expect(browser.executeScript('return window.angular.version.full;')).
toEqual('1.3.0-rc.3');
Longer example passing a function instead of a string plus without expect resolving the promise for you. i.e. for more control and for doing some fancy thing with the result.
browser.driver.executeScript(function() {
return window.angular.version.full;
}).then(function(result) {
console.log('NodeJS-side console log result: ' + result);
//=> NodeJS-side console log result: 1.3.0-rc.3
});

Upgrade from .net 4 to 4.5 breaks Html.Raw call in Javascript

I have the following code in a c# MVC 3 razor page where I am passing serialized data into a javascript variable for KnockoutJs:
#{
var listData = new JavaScriptSerializer().Serialize(Model.ListItems);
var pagerData = new JavaScriptSerializer().Serialize(Model.Pager);
}
// additional code
<script type="text/javascript" >
var ListData = #(Html.Raw(listData)); // <-- Syntax Error here
var PagerData = #(Html.Raw(pagerData)); // <-- Syntax Error here
// additional js code
</script>
After upgrading to VS 2012, I am getting error squiggles after the javascript semi-colons at the end the Html.Raw lines above. The project complies but VS 2012 displays 'Syntax Error' in the Error List for each line. Without the semi-colons the javascript also shows a 'Syntax Error'.
This code worked without issues in the previous version. Is this a bug in the VS 2012 parser and is there a way to avoid the generated errors?
Edit
Anyone else seeing this issue? Below is a simplified version with the same issue isolated in a new page. If you add a semi-colon at the end of the ListData line you get a javascript syntax error, without one it is on the next line. Is this a bug in the javascript compiler between VS2010 and VS2012?
#{
var listData = "test";
var pagerData = "test2";
}
<script type="text/javascript" >
var ListData = #(Html.Raw(listData))
var PagerData = #(Html.Raw(pagerData))
</script>
Please add vote on this connect issue. We will address this issue in next version of VS. I have attached your repro code to this bug and added link to this post as another manifestation of the issue.
This issue still exist in Visual Studio 2013 SP 2
To fix this warning message initialize javascript variable first. IMO Visual studio think var as implicitly typed if any var followed by #.
var ListData;
var PagerData;
ListData = #(Html.Raw(listData));
PagerData = #(Html.Raw(pagerData));
I'm using MVC5 and finding the same issue, so I solved it this way, which should work in all versions
#Html.Raw("var myData = " + Json.Encode(this.Model.MyData) + ";" )
However, I would use this only in the simplest situations since you lose any intellisense as to VAR type (although it does treat it as a global instance and the compiler doesn't throw a wobbler), so for now I think an initial, empty definition is probably the best way to proceed.
I have had the same thing happen, but it does so at random.
What I have tried to resolve it is the following:
Make sure you can compile/build/debug in Debug mode, switch to Release mode and attempt to debug/publish from that mode.
Switch back to Debug mode and re-attempt the publish.
Some combination of switching modes does the trick, I just can'y nail down what it is exactly.
Once you get it working, don't close VS ;-)
Let's hope MS gets this fixed in SP1.

Selenium IDE: this.browserbot.getUserWindow().typeList.filter returns error on IE8

I have faced with following trouble during working with Selenium.
I need to verify that some value exists in list and I use the following code:
assertEval
this.browserbot.getUserWindow().typeList.filter(function(v) { return v[0] === 'Type_${r_suffix}'; })[0][0];
Type_${r_suffix}
This works file on Firefox, but on IE 8 returns error: Object doesn't support this property or method.
Could someone have an idea where is a problem?
As the MDN docs say, the filter() method is available only for IE9 and above.
Your're just using a too new technology. Filter it manually using a for loop or insert the code for Array.prototype.filter (from the MDN) to have access to it.