Tuesday, March 27, 2012

Friday, February 17, 2012

Type was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.

While working on a GWT application incorporating a SuggestBox and a custom suggestion oracle class I got stung by the following error:

"Type 'custom suggestion class' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialised."

The solution to my particular problem was to move the custom suggestion class into the client side package (it needs to be on the client side).


Decided to put a post up about this solution to the problem because it has a very faint web foot print, most other suggested fixes are about creating a empty constructor for your suggestion class. 

Sunday, January 15, 2012

Cannot read fields from a deleted object

The above error was causing me some grief, I did delete the object but for some reason a populate query was picking it up from the datastore.

I was able to check if the object was deleted with the following JDOHelper function: JDOHelper.isDeleted(item)

I used it as follows:


import javax.jdo.JDOHelper;
import javax.jdo.ObjectState;

public List getWatchList() {
List watchList = new ArrayList();
List result = ccs.myasxpager.datasource.WatchList.getWatchList();

for (ccs.myasxpager.persistence.schema.WatchList item : result) {
if (JDOHelper.isDeleted(item))
continue;
String[] watchListItem = {item.getAsxCode(), ccs.myasxpager.datasource.Company.getCompanyNameByCode(item.getAsxCode()), ccs.myasxpager.datasource.Company.getIndustryByCode(item.getAsxCode())};
watchList.add(watchListItem);
}
return watchList;
}


Monday, September 13, 2010

Using XmlReader to parse an XML file

using (XmlReader reader = XmlReader.Create(@"D:\Temp\XMLReader\XMLReader\ViewFields.xml"))
{
// Parse the XML document. ReadString is used to
// read the text content of the elements.
while(reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name.Equals("viewfield"))
{
reader.ReadStartElement("viewfield");
Console.WriteLine(reader.ReadString());
}
}
}
}
Console.Read();

Monday, July 5, 2010

Accessing the Content Fields of a SharePoint page

I needed to access the properties/content fields of a SharePoint page programatically and achieved this with the following code:

SPField field = SPContext.Current.List.GetField("Level 1 Group Summary");


string value = field.FieldRenderingControl.ListItemFieldValue.ToString();

Or
value = field.FieldRenderingControl.ItemFieldValue.ToString();

Wednesday, April 7, 2010

Decimal Regular Expression

The following regular expression checks for a number that can contain up to two decimal places.

^\d*(\.\d{1,2})?$

matches:

123
123.1
123.12

not matches:

123.
123.123

Monday, March 29, 2010

NSMailDelivery undeclared

I've been playing around with Objective C using the Cocoa framework ever since I got my Mac for Christmas.

I was following a dummies guide to sending emails using Cocoa and I came across the following show stopper compilation error :

"error: 'NSMailDelivery' undeclared (first use in this function)"

Not much joy online looking for a solution, seems everyone else who was inflicted with this error was advised to use some other mail class due to NSMailDelivery being dropped by Apple with no successor in Cocoa which seemed odd.

Anyway here's how I solved the problem. By default on my Mac Cocoa projects are targeted for a 64 bit architecture environment, when I changed the architecture to 32-bit universal the project compiled.

I changed the target architecture by clicking on the project name under "Groups & Files" to highlight it.
Then I clicked on the "Info" icon to open the project info dialog, next I clicked on the "Build" tab and changed the architecture value to "32-bit Universal".

I'm guessing switching to a 32 bit architecture will fix simular error messages with different classes I saw people enquiring about while I was looking into this problem.