Skip to content

Silverlight Image Error

While working in Silverlight I ran across a error that seemed rather odd, not because it didn’t make sense but that I couldn’t see anything I did wrong. So the error was

Unhandled Error in Silverlight 2 Application App.xap
Code: 4001
Category: ImageError
Message: AG_E_NETWORK_ERROR

While checking the Image tag in the xaml I simply couldn’t find anything wrong with it. It looked very similar to the following xaml. The user.profile_image was of course a full URI that worked fine when written directly in the browser.

1
   <Image  Grid.Row="0" Margin="0,0,5,0" VerticalAlignment="Top"  Source="{Binding user.profile_image}" ></Image>

So that leaves me with what could the problem be, well it turned out it was simple I was a using a GIF file so http://mydomain.com/foo.gif as a source for an image simply doesn’t work as GIF isn’t supported. But really why would Silverlight not use GIF? Well simply converting the GIF to a PNG then Silverlight can handle the image just fine and display it. Although there are some issues as in Silverlight the only 8 bit and fewer PNG formats support transparency. So if the reason you were using a GIF was for transparency you will have to create an 8 bit or lower PNG. Look for a simple how to next post on converting a GIF to a PNG that Silverlight can display properly with transparency.

Connector/J 5.1.6 vs Connector/J 5.1.7

While deploying a Java based auto import system I ran into a very odd problem. The code was developed and tested just fine with Connector/J 5.1.6 then while pushing to prod there seemed to be a major issue, the import would run download everything parse it and then clear out the old data but then get stuck. I would then get a series of errors java.sql.SQLException: !Statement.GeneratedKeysNotRequested! well it turned out that the prod sever had Connector/J 5.1.7 installed instead of the 5.1.6 which test had installed. This turned out to be allowing for some wrong practices when it came to prepared statements. It was a pretty easy fix yet it took a bit of time to make sure it happened every where. So why there was a change and what happened is well discussed else where and the links to those will follow. But for now here the change that needs to happen.

1
PreparedStatement postinsert = connection.prepareStatement(sql);

Just changes to the following. But make sure you do the change for all prepared statements that will use generated keys, its easy to miss one and have the whole app fail because of it.

1
PreparedStatement postinsert = connection.prepareStatement(sql,PreparedStatement.RETURN_GENERATED_KEYS);

Continue reading ›

Silverlight Move Cursor to End of TextBox

While working on in Silverlight I found the need to auto populate a TextBox then shift focus to that TextBox. That was simple to do with the following code.

1
2
txtSearch.Focus();
txtSearch.Text = "sometext ";

But then there is a problem the cursor is at the start of the text box so if a user starts typing they end up adding to the start when I want them to just add on to the end. So after some hunting I found the SelectionStart property of the TextBox, while this may be obvious to people who work in Silverlight and C# all the time it didn’t jump right out at me so I thought it was worth talking about. So by using SelectionStart and I can move the cursor to the end and users can just append to my started search text.

1
2
3
txtSearch.Focus();
txtSearch.Text = "sometext ";
txtSearch.SelectionStart = txtSearch.Text.Length;

Go Daddy Subdomain Redirects

After seeing this great post from Jamie Thingelstad about using subdomains to redirect people to your LinkedIn or Twitter profile I thought it would be great to add that to my site.

But it was a big process that it shouldn’t have been. I found it very hard to actually find where in the my Go Daddy hosting where to put the subdomain. So if you are doing hosting with Go Daddy and have used their subdomains tied to a folder you have to goto a completely different section to do this type of redirect. It’s in the domain management which one would expect but I look right past the correct section at least a half dozen times, so below there is a picture below the fold with a red box showing exactly where to add the subdomains.

The process is simple once you find the correct section. Simply click add then fill out the “subdomain” and “forward to” fields as an example I did “subdomain”: twitter and “forward to”: http://twitter.com/beckje01 Those simple steps have now set up http://twitter.jeffbeck.info to link to my twitter account.

Continue reading ›

YUI ScriptNodeDataSource Issue

While using the YUI Library, I came across an annoying issue. It is stated places that order matters when dealing with the library includes, yet there are still some issues that come up. The main one I’ve found is with the YAHOO.util.ScriptNodeDataSource this is used for accessing remote data via the YUI Get Utility. But using the configuration from Yahoo the Get library isn’t included by default, yet when you add it after finding that error the system still won’t work.

The Get Utility has to be loaded before the DataSource library, yet this is the only part of the DataSource library that require the Get utility so it isn’t listed as a dependency for that library. I used the YUI Dependency Configurator yet while working without the combined files you can still introduce the ordering issue. Yahoo needs to add a simple check that the Get utility is always loaded before the DataSource Utility yet that haven’t yet. You may not have this issue while using the combined files mode as it will all be executed at once.

So if you see an error message like “this.getUtility is undefined” make sure you have the Get Utility loaded before the DataSource.

Quick GWT Note

While working on a small GWT project with two other developers I ran into an odd runtime exception “com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException” as I was testing my app in the hosted mode I’m not sure how to refresh that built in browser which is the listed fix. What I ended up doing was a simple clean of the project which solved my problem, I think it relates to how I’m using SVN not integrated into Eclipse with the project yet its hard to tell. But if you run accross this expection try a simple clean before pulling too much hair out.

ExpressionEngine Pagination and Get Parameters

This may not come up that often but if you are using Get parameters such as lets say submitted by a form to filter some weblog entries, these parameters will not be preserved while using the built in pagination. This can be a real issue if you are trying to filter results and let users page through them but we can add a touch of PHP and fix this issue. In your paginate tags we just need to add the query string to the page link. You’ll notice in the sample we use the server parameter ‘query_string’ along with the question mark which will produce our correct links.

1
2
3
4
5
6
7
8
9
{paginate}
  {if previous_page}
    <a href="{auto_path}<?php echo "?".$_SERVER['QUERY_STRING']; ?>" class='paginate-previous'>Previous</a> &nbsp;
  {/if}
 
  {if next_page}
    <a href="{auto_path}<?php echo "?".$_SERVER['QUERY_STRING']; ?>" class='paginate-next'>Next</a>
  {/if}
{/paginate}

ExpressionEngine Pagination and the Dynamic Parameter

While working with an ExpressionEngine based site I ran across a listing of a weblog that could contain 1000’s of posts yet as it was displayed with the Dynamic Parameter off there was no stock way to support Pagination of the items. I used a simple hack, shown at the end of the post, that allowed me to use the pagination but it shows a bigger issue with ExpresionEngine, while it may not come up that often there still should be pagination for any exp:weblog:entries set but it is not. There is no reason that non-dyanmic listings shouldn't be paginated if anything it would be more likely needed as they are likely to be a long list of a whole set.
Continue reading ›

wget and special characters

While using wget with authorization to download some data you may run into the problem of having a special character such as ‘>’ in your password. It’s a simple fix of wrapping your password in quotes. But the only error message that this problem will give is an authentication failure.

JavaScript / Flash Chart Alternative

So many times it is nice to add a dynamic graph to a web page. I’ve personally done this with JavaScript libraries like PlotKit or Plotr. Also there is the use of Flash with PHP or ASP.Net in amCharts. But if the user doesn’t have Flash or JavaScript turned off these tools fail. While this doesn’t happen too often any more it still may be an issue. But one issue I’ve noticed is that these charts do take a lot of resources to run so if you have visitors with slower computers that may be a real issue.

So we need a simple alternative, such as generating an image server side and serving that up. While this isn’t too difficult you may not have an imaging library available or the resources to spare. That is where Google Charts comes in with their simple API you can quickly add graphs to your web page. It’s really simple just embed a special URL in an image tag which you can easily make dynamic with PHP, ASP, or any dynamic system you’re using. See the example below. It works very well, with minimal setup and no added software for clients is needed.
Continue reading ›