Monthly Archives: January 2011

Taiwan Q Q

For the uninitiated, Q Q isn’t just a sad face emoticon, but is actually also a descriptor for food here in Taiwan (and I imagine in some other Asian countries, but possibly not…)

You’ll often see people touting their food as being “Q”, which a lot of people seem to like here.

But what exactly is Q? Apparently, it means chewy…but in a nice way. Some sort of medium between al dente and chewy. Things like mochi, well cooked noodles and good pearl milk tea pearls are all Q.

The more you know!

Taipei’s Public Transportation Is Awesome

When my aunt says “the metro is a little slower at night, you’ll have to wait 10 minutes for a train”, I think back to Auckland and I laugh. I laugh, and I wish I could pack up Taipei’s fantastic public transport system and plant it right into Auckland. (I guess the other half of the problem is things to do in Auckland, but I digress)

There’s a version of Wellington’s Snapper card here; it’s called an Easycard, and it’s freaking amazing. I love it to pieces.

You can also pay for a lot of things with it, as most convenience stores accept it as payment, and you don’t even have to take it out of your wallet – it uses some magical near-field goodness or little electronic elves to automatically read and deduct from your card. Somewhere out there is probably an elite hacker running around with an unlimited card…

It’s accepted not just on the metro but buses too, and you get a discount if you’re transferring from one to the other, presumably as their way of apologizing for not being able to take you from door to door. The only gotcha when riding the buses here is you need to know whether to pay when getting on, or off the bus; and this is only written in Chinese so it’s not immediately obvious for illiterate fools such as myself, but:

上車 means you pay when you’re getting on the bus

and

下車 means you pay when getting off the bus

Luckily, they kind of look like up and down arrows (and okay, I do remember up and down from my very very early Chinese learning days), but it definitely caught me off guard when I first got on a bus here.

Anyway, Auckland’s public transport sucks. But with so many places to visit and so many people in Taipei, I don’t think anything less than this level of mass transit excellence would do.

The Only Thing Worse Than Being Sick

Is being sick on holiday; and the only thing worse than being sick on holiday is being sick for an extended period of time while on holiday.

I guess it takes sickness for people to truly appreciate good health, but it’s been pretty annoying progressing from a runny nose to a debilitating cough, turning into stomach cramps and then a sore throat. None of it is probably life threatening, but it’s definitely fun-threatening.

Keep well, everyone!

Submitting A WP7 Application Update

If you’re a Windows Phone 7 developer like me, and you’ve submitted (and successfully pushed through) an update for your application to the Marketplace but haven’t been prompted to update your application in the marketplace, don’t panic.

This happened to me, and I was pretty worried that something had gone wrong, but it turns out that Application Update notifications don’t happen at the same time that application updates are actually published to the marketplace. Furthermore, they don’t seem to be going out to all phones simultaneously, so if someone else is able to update their version of your app but you aren’t, give it at least two days before you freak out!

This is also a roundabout way of saying that Noborizaka version 1.1 has been released to the marketplace – check out the application/download for further details!

Adding Linebreaks To The Default Value For InfoPath Multi-Line Textboxes

EDIT: I went over this post again, and I have no idea what I was on about. You can just set the Display setting to Multiline, and adjust the height of the box using the size field. I’m still confused as to why I thought the below was the only option…so, yes – you could add linebreaks to the default value; but I don’t really know why you would, now that I think about it…maybe the reason will come back to me one day, though it’s pretty likely that I was just out of my mind when I posted this.

This is quite possibly the hackiest thing I’ve done all week in InfoPath. To add multiple breaks in InfoPath is actually pretty easy. If you’re looking at the standard Default Value box, you might be wondering how to get it to accept enters, since it’s a single lined field…



Don’t sweat though, we can use some XPath magic to work around this. Click on the fx / function button next to the text box to bring up the formula view, where you’ll need to enter:

string(”




“)


Easy enough, right? Well, if you try typing that by hand, you’ll soon realise hitting Enter or Ctrl + Enter or any combination of keys including Enter will close your formula window, so you must write the text out somewhere else, copy it, and then paste it in manually.

One reason why you would want to do this is to set minimum heights for dynamically sized text boxes – there’s no way to specify a minimum height for a multi-line text box, so the closest thing you can do is to push out the box by pre-populating it with a whole bunch of line breaks. Take note that all the extra whitespace gets trimmed the instant a user enters any content though, and I’ve found that the dynamic resizing is a little bit flaky with browser-enabled forms (but works as expected with InfoPath Filler).

In other news, I’m taking some leave to head to the awesome country of Taiwan for a month to visit relatives, relax, buying lots of stuff, etc. This means that there will be a distinct lack of, technical, programmy, what are you talking about, Henry posts. Hurrah!

InfoPath Validation And The Errors Property

When developing InfoPath forms, sometimes doing your validation using rules in the designer isn’t quite powerful enough. Luckily for us, InfoPath allows you to hook into the Validation event for controls within your form; but here’s something to watch out for.

When developing a form that attempts to access the Errors property of the current form from within a Validation event, although it will work fine with InfoPath Filler and local forms, you may get an error that looks similar to the following when you deploy it as a browser-based form to a SharePoint instance:

Exception thrown from business logic event listener: Microsoft.Office.InfoPath.Server.Util.InfoPathLocalizedException: Calling this property or method from a hosting page is not supported.
at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.EnsureDocumentIsNotInMode(DocumentMode mode, Ids exceptionMessageId, Object[] resourceParameters)
at Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost.get_Errors()
at Microsoft.Office.InfoPath.Server.SolutionLifetime.XmlFormProxy.get_Errors()
at LiabilityForm.FormCode.Attachment_Validating(Object sender, XmlValidatingEventArgs e)

Doing a bit of reflection shows us exactly where the code dies:

[sourcecode language="c-sharp"]
public override FormErrorCollection Errors
{
get
{
EnsureDocumentIsNotHostRestricted(this.Document);
this.Document.EnsureDocumentIsNotInMode(DocumentMode.VersionUpgrade, InfoPathResourceManager.Ids.VersionUpgradeOMErrorProperty, new object[] { "Errors" }); //error thrown on this line
OMSecurityContext.ExecuteOMCall(this.Document.Solution, SecurityLevel.Domain, delegate {
if (this._errorBoardPublic == null)
{
this._errorBoardPublic = new ErrorBoardPublic(this.Document.ErrorBoard);
}
});
return this._errorBoardPublic;
}
}
[/sourcecode]

The DocumentMode.VersionUpgrade is a little bit of a red herring in this instance – I initially thought that my code was failing due to some issues around my form deployment and potentially the form being locked in some sort of version/update limbo, but actually it turns out that you just shouldn’t access the Errors property from within the Validation event (in the same way that any attempts to modify the form will also raise an exception.)

While normally you would be able to use e.ReportError() and continue as normal, it won’t work for cases where you have “validation control pairs” where a change to one control should also trigger validation, and you need to raise errors targeted at a control of your choosing (not just the parent control of the Validation event).

Instead, you need to switch to the Changed event – this will allow you access to the Errors collection, but will unfortunately be slower as it requires a roundtrip to the SharePoint server, and there will also be some visible flashing/reloading of content. Don’t forget that you’ll also have to set all the controls you intend to validate in this fashion to always postback the data to the server, otherwise the validation won’t get called at the correct time – you can do so from the Browser Forms tab in the target control’s Properties:

I couldn’t find a lot of information out there about DocumentMode.VersionUpgrade, or around this gotcha in general – even the MSDN article on XmlEvent.Validating shows an example using the Errors collection directly, but it definitely wasn’t working for me within the browser on my checkboxes and attachment control. If anyone has encountered a similar issue, or has any more insight to the problem in general, please feel free to comment below.

WP7COMP Entry: Noborizaka

Redgate (creators of the ever popular .NET Reflector and the SQL comparison tool whose name escapes me, for now) are currently running a Windows Phone 7 competition, for which I have submitted my app, Noborizaka. If me and some workmates get our gear together we might be able to pull off a second entry, but I didn’t want the opportunity to pass by, at the very least for some more exposure for Noborizaka!

Take a look at the competition website here, and I’d really appreciate as many Likes as everyone can muster up!

In other news, Version 1.1 of Noborizaka should be submitted to the marketplace any day now – it includes live tile updates, action notes and some bug fixes. While doing so, I managed to get some download stats as well, and it’s tracking well on its way to 1,000 downloads. If you’re one of the 1,000 people using Noborizaka, I would love to hear from you, especially if you have any feedback or suggestions!

Also, have a look at the download trendline right after Christmas – that’s the Christmas effect alright…

Pro Tip: InfoPath Read-only Views

Hopefully this saves someone some time – if you’ve got an InfoPath form where you want to present a standard editable view and a “read-only” version which should not be editable (such as when you want to disable form editing for forms hosted in a SharePoint Form Library that have not been checked out), you can set your entire view to read-only, instead of attempting to replicate the entire view and modifying every single control.

In InfoPath 2010, under the Page Design tab in the Ribbon, clicking on Properties under the View Selector will present you with the following dialog where you can enable/disable read-only for the current view:

There are two main benefits to setting the entire view to read only:

1) It’s obviously a lot faster and more fun than going through your entire form and setting all the controls to read only.
2) Some controls, such as the Person/Group picker, don’t have a read-only toggle in their control properties. However, setting the View to read-only will work for these controls.

If you need a view where parts are editable and parts are not as well as a read-only people picker, you’re probably still out of luck – but if you are creating a read-only view like I was, setting the entire view to read-only is definitely recommended.

EDIT: Note that in read-only mode, File Attachment controls will annoyingly not allow users to open/view the attachments. Which is rather bizarre, since opening a file is pretty much reading it, and being unallowed to do so in a read-only mode is perplexing…if anyone is aware of any workarounds for this, please leave a comment!