28 mars 2010

Size of the text in a SC.LabelView

to change the size of the value in a SC.LabelView simply add the following property:
controlSize:

available settings:

SC.HUGE_CONTROL_SIZE
SC.LARGE_CONTROL_SIZE
SC.REGULAR_CONTROL_SIZE
SC.SMALL_CONTROL_SIZE
SC.TINY_CONTROL_SIZE

16 mars 2010

SproutCore Datasource

So i built my first application in SproutCore. An IP-Management application which fetches available IP-addresses from the inventorysystem my department uses.

It was really easy to build the application using fixtures and when my datasource and backend was ready i just switched the store to "store: SC.Store.create().from("MyApp.DataSource")," and i had real data in my application!

Basically MyApp.DataSource is a base set of functions which is called when certain functions are called. As i dont have any need to write data back to the server in this application i only have use for fetch().

My fetch-function passes what store made the request and what query was used:

fetch: function(store, query) {
// Check what query was used. Add more else if, if your application handles more data-models
if (query === SC.Query.remote(MyApp.Subnet)) {
//Initiate a server request for all the subnets available in JSON-format
var serverRequest = SC.Request.getUrl('/data/subnet').json();
//Tell SproutCore what object and what function it should call up a response, pass query and store
serverRequest.notify(this, this._didFetchAllSubnets, { query: query, store: store });
//I want all my data loaded before continuing
serverRequest.set('isAsynchronous', NO);
//Finally, send the request
serverRequest.send();
//return YES (true) to indicate we handled the fetch.
return YES;
}
}

The function which will be called upon a response is "_didFetchAllSubnets" as specified in the .notify() function above. This function needs to call at least 2 functions upon reading the data, check out this function:

_didFetchAllSubnets: function(response, params) {
//Get the parameters passed from the request
var store = params.store;
var query = params.query;
// Only if the response is ok we would want to read it into the store
if (SC.$ok(response)) {

// load the data into the store and save the storeKeys
storeKeys = store.loadRecords(MyApp.Subnet, response.get('body').content);

// notify store that we handled the fetch and hand it the storeKeys
store.dataSourceDidFetchQuery(query,storeKeys);

// handle error case
} else store.dataSourceDidErrorQuery(query, response);
},


And that reads the data into the local store and can be presented. One thing i learned is that if ur missing one of the specified fields in the data-model, it wont be able to use the data. I missed out on the guid (this was generated just before sending the data from my php-script), i had it commented for some reason. This generated an error of "dataHashes.len is not a function".


Almost every line of this code is taken from http://wiki.sproutcore.com/DataStore-Introduction

Attaching an event to a view

myView: SC.ListView.design({
eventToHandle: function() {
return YES;
}
})


This attaches an event to a view. I havent found a list of available events yet but i shall post it as soon as i find one.

SproutCore

This is an excellent framework as it allows simplified web-based application-development. The framework itself is written in ruby and the applications published are written in javascript.

First of all it has a design-framework which is based on views and subviews. It comes with a default theme and it is nice enough if you dont have the skills to design it yourself.

http://www.sproutcore.com/ - Take a look under Demo


More to come.

11 december 2009

Timeout

A strange problem rose with the release of Firefox 3. Pages takes forever to load.

After alot of thinking and testing weve come to the conclusion that its the http timeout value in about:config (which defaults to 300). Its in conflict with the timeout value of our firewall for the HTTP-Protocol.

The setting in the firewall is 60 seconds which means that if a http-connection lasts more then 60 seconds in firefox (it will last 300 seconds) the firewall expects a TCP-SYN packet to start a new http-connection, firefox however will NOT start a new connection since it thinks it is still connected. The firewall will look at the next packet and think its out-of-state, which makes firefox "load" the page until it reaches its timeout value (300).

The solution to this specific problem is to set the http timeout value in firefox lower then the one in the firewall to make firefox initiate a new conneciton before the firewalls timeout ends.


10 november 2009

iPhone & Contacts

Having a list of contacts in my iPhone is a bit of a problem.

I can have a LDAP-contactlist BUT i dont have a button to import the LDAP-contact into my iPhone contactlist. Why is this?

9 november 2009

iPhone & eGroupware 1.4.002

I just got an iphone at work and ive been trying to get it to sync my calendar. It didnt matter if its a 2-way sync or just a readonly calendar in my phone. I just want to know whats happening during work hours.

iPhone OS 3.1.2 has support for CalDAV calendars, eGroupware 1.4.002 has not.

After playing around for a while (and browsing app store for a few hours) i suddenly noticed, u can subscribe to calendars. This works with eGroupware 1.4.002. Just insert ur /icalsrv.php/username/whatever/events.ics (or default.ics) and ur back on track! Your calendar in your iphone!