22 November 2007

Symbolic link

Keep forgetting how to add a framework:

cd /Libarary/Frameworks

Then add your framework like this example with EkjaFramework in my Developer workspace:
ln -s /Developer/workspace/EkjaFramework/dist/EkjaFramework.framework/ EkjaFramework.framework

15 November 2007

WOCheckBox binding

Keep forgettins it's the cheked binding to use, not value or selection.

24 October 2007

S5 slide show presenter

Online presentations S5 is a great tool for setting up slides shows in a browser. Check out the intro.

19 October 2007

My favorite Eclipse shortcuts


Select the current word

Ctrl + Shift + left/right arrow

Comment out selected lines

Opt + 7

Open Type

+ Shift + T very handy when you know the name of the class you need to check

Move selected lines up/down

Alt + up/down arrow

Copy selected lines up/down

Alt + Shift + up/down arrow

Bring up refactoring menu

Alt + Opt + T

Insert WOComponent

Opt + 6

Rename WOComponent

Opt + 2 then R

18 October 2007

SQL Server 2000 IDENTITY_INSERT

SQL Server has got identity for primary keys( see this article ) that was preventing me from inserting into a table with EO.

To get by this you can just set the identity insert to on with:

EOUtilities.rawRowsForSQL( ec, modleName, "SET IDENTITY_INSERT tableName ON", NSArray.EmptyArray );

Note that you might need to get the new primary key( identity ) yourself, ex.:

NSArray rawRows = EOUtilities.rawRowsForSQL( ec, modleName, "SELECT MAX(idenityColumnName) as NR FROM tableName", NSArray.EmptyArray );
NSDictionary rowWithPK = (NSDictionary)rawRows.objectAtIndex(0);
Object maxPK = rowWithPK.objectForKey("NR");
int primaryKey = (new Integer(maxPK.toString())).intValue();

11 October 2007

Icelandic keyboard

When traveling around one might feel the need to have access to Icelandic keyboard input. Only tested this on IE, need to enable other browsers... sometime ;)

Icelandic to HTML converter

When you can't save the icelandic text, it's good to have a quick way to convert Icelandic into HTML

04 October 2007

Gmail's quick preview

Right clicking a message will bring it up in a floating container, pretty neat.

03 October 2007

Get parameter from URL

Creating a cover method for the parameter with:

context().request().stringFormValueForKey( "parameter" );

will always give me what I want ;)

02 October 2007

Long WO

When my WebObjects span over a lot of space you can also set the name property of the closing WO tag to distinguish where that WO ends.


... lots of content

Language dictionary

Set you user defined dictionary
A lot of the words we use in our comments are specific to our work. You can add your external dictionary by doing the following:
Open Eclipse Preferences - General - Editors - Text Editors - Spelling
Under Dictionaries set a file for the User defined dictionary

Application Memory size

Add -Xmx400M in the Arguments launch configurations.
400 is the size of the VM heap size in MegaBytes in this example, the default size is 64.

Distinct WOPort number for each application?

Run any of your projects simultaneously.
Browser shortcuts to all of your projects.
Open the launch configuration for you project and change the WOPort parameter to a unique number( ex. 1200 and up )

Auto connect to the deployment database

In the WO launch configuration add:

-Dis.us.useDevelopmentDatabase=true

the D notes that this is a Java property

Organizing your favorite launch configurations

Click the little triangle next to the Debug As... bug icon and select Organize Favorites
Click the Add button to insert a new launch configuration onto the top of the Debug As... list.

Changing an old launch configuration

Open Run - Open Debug Dialog
Under WOApplication you can change the settings of each of your launch configurations, and add new ones.

Changing the default settings for a new WOApplication launch configurations

Open Eclipse Preferences
Under WOLips and Launch you can change the settings

Disable auto opening of browser at launch

In the WO launch configuration set:

-WOAutoOpenInBrowser=false

Remove "Use Eclipse Browser" from the Browser launch configuration.
Add this to your default WOApplication launch preferences

Disable the WebServicesAssistant at launch

Add the following parameter into the WO launch configuration:

-WSAssistantEnabled=false

Add this to your default WOApplication launch preferences

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() );
    }