27 September 2007

Fetching raw rows

setFetchesRawRows( true ); must be set before setRawRowKeyPaths

WOImage with data binding

A WOImage with data bound to NSData( read from DB ) was not showing up on print.
Binding the "key" to a unique identifier for every image did the trick.
Hugi pointed this out to me, he had run into it some years ago, seems the NSData is only kept for a short period of time in the cache and setting the key will extend it's lifetime there.

24 September 2007

UNIX find pattern

Find text in files:
grep -c -r pattern file

-c fyrir count, telur hverstu oft kemur fyrir
-r fyrir recursive, fer ofan í undirmöppur

e.x. grep -c -r logi *
search all files/folders for "logi"

...havn't tried the "find" ;)

Unix du

du -hcd 1
list all directories, down 1 level( d 1 )
in human readable form (h) and total count( c )

Unix ls

ls - lt : returns (l)ist ordered by (t)ime
head : return top 10
=>ls -lt | head
ls -1 return single column name only

Subversion path

export PATH=$PATH:/opt/subversion/bin

Go to folder to work with

to commit: svn commit -m "Message description"

20 September 2007

Unique ID for element

When working with JavaScript I often need a unique ID for the current component I'm woking with:


ERXStringUtilities.replaceStringByStringInString( ".", "_", context().elementID().toString() );

Get previous page name

I wanted to enable the user to go back to the previous page without using a WOActionResults to set the name of the component calling the nextPage. WOContext has a method called page that did this for me with ease ;)


String previousPage = context().page().name();

Gmail icelandic spell checking

I just learned that Gmail has a build in spell checker. The nice thing is that it works with a lot of languages, including Icelandic ;)

Gmail spell checker

19 September 2007

SQL output from WO

-EOAdaptorDebugEnabled YES

Kill process on port

lsof -i tcp:PORT_NUMBER

new WOComponent instance

Need to create a wocomponent instance in java, you'll need : Application.application().createContextForRequest( new WORequest( "GET", "", "HTTP/ 1.0", null, null, null) ) to create the request

WOFileUpload

Created a WOFileUpload and connected the inputStream attribute to an input stream but nothing worked, kept getting a NP untill I connected FilePath to a String variable, then the WOFileUpload worked like charm( annoying charm that took too much of my time to figure out ).

Icelandic thousand seperator

application.icelandicNumberFormatter in the "formatter"-attribute.

Date Formatting


// Use SimpleDateFormat to format the display of date Strings
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
return sdf.format(new Date());

Read file contents

// Read each line of the file infile.txt


BufferedReader rdr = new BufferedReader( new InputStreamReader(new FileInputStream("infile.txt"), "ISO-8859-1"));
String line = rdr.readLine();

Overwriting valueForKeyPath

I need to access a localalized strings file for the right language and I don't like the Localizer method.
I wanted to access it through Application and in the WOD files by simply adding "application.@ls.MY_STRING_TO_GET_FROM_LOCALIZED_STRING".

Added the following to Application.java:


  public Object valueForKeyPath( String keypath ) {

// Catch all keypaths starting with ls and do whatever you want with it
        if( keypath.startsWith( "@ls" ) )
            return localizedStringForKey( keypath.substring( 4, keypath.length() ) );

        return super.valueForKeyPath( keypath );
    }

    public String localizedStringForKey( String key ) {
        return WOApplication.application().resourceManager().stringForKey( key, "localizedStrings", "!!LOCALIZED_STRING_NOT_FOUND!!", "app", languages() );
    }