IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New WebObjects Answers
1) What would be a good design practice for enabling components to speak more than one output dialect? ie. an HTML output format and an XML format


Hmmm. Components get their chance to emit their output in appendToResponse (in the java version) or it was called appendToResponse:inContext: in ObjectiveC. If you're using GSWeb I'll assume its Objective C from here on out. The main loop looks like:

Application>>handleRequest:
Session>>awake
Session>>takeValuesFromRequest:inContext:
Page>>awake
Page>>takeValuesFromRequest:inContext:
Components>>takeValuesFromRequest:inContext:
-- at this point everything is about copying state from browser into session/page/components
Application>>invokeAction:
Session>>invokeAction:
Page>>invokeAction: (your action method gets called -- ie whatever action was bound to the link/button they clicked - if any - you should return the next page or nil if you want to redraw the current page)
-- so you did something now answer the response
Application>>appendToResponse:inContext:
Session>>appendToResponse:inContext:
Page(the new one)>>appendToResponse:inContext:
Components>>appendToResponse:inContext:
-- after this - sleep gets called on everything that got an awake call.

2) Similarly, design practices for internationalizing output.


I have a vast amount of code that does this stuff. Out of the box, WO wasn't entirely international ready - I don't know about GSWeb either. We developed components that automatically internationalized stuff. So instead of WOString we used ETString everywhere. What these components did was look at what you would normally emit in appendToResponse:inContext:, notice what locale was in the content/type header (which we set up in Application early in the loop), then open a resource file and get the appropriate translation for the string that was supposed to be emitted. A strings file is basically a dictionary plist with the english text as a key and the translation as a value. Thats translation. We wrote number/date formatters that did internationalization too. The idea was to just write the app as if it were in english, then the components would deal with internationalization. There is also a locale bundle mechanism that lets you serve a completely different page based on locale. The idea is you have a resource directory for each different language - like Spanish.lproj. WO will try the specific resource dir first, then fall back to the main one. So if you wanted to do a site for hebrew and lay everything out right to left, you'd put all the page resources for the hebrew site in Hebrew.lproj, but use the regular layouts for all the other languages and just use strings files.

3) And this one is probably going to prevent me from using GSWeb: those stupid URLs. They make a persistent URL impossible. Any strategies to get around that?


There is a thing called a direct action - these are bookmarkable - but you don't have session information (obviously) in a direct action. The response loop is a little different for DAs. It looks like:

Application>>handleRequest:
DirectActionClass>>alloc // a new instance of the DirectActionClass is created
DirectActionClass>>yourActionMethodWithTheRequest: // you return the response





I think that it's extraordinarily important that we in computer science keep fun in computing. When it started out, it was an awful lot of fun. Of course, the paying customer got shafted every now and then, and after a while we began to take their complaints seriously. We began to feel as if we really were responsible for the successful, error-free perfect use of these machines. I don't think we are. I think we're responsible for stretching them, setting them off in new directions, and keeping fun in the house. I hope the field of computer science never loses its sense of fun. Above all, I hope we don't become missionaries. Don't feel as if you're Bible salesmen. The world has too many of those already. What you know about computing other people will learn. Don't feel as if the key to successful computing is only in your hands. What's in your hands, I think and hope, is intelligence: the ability to see the machine as more than when you were first led up to it, that you can make it more.

--Alan Perlis
New Re: WebObjects Answers
The main loop looks like:
Right... I knew all that. What I was asking was what are the best practices for outputting XML one time, and maybe HTML the next, from the same set of objects. Or is it just best to use a different page/set of components against the same business objects?

We developed components that automatically internationalized stuff.
OK, this sounds very, very similar to what I did with J2EE.

but you don't have session information (obviously) in a direct action.
That's the issue. I'm not sure why they didn't just store a single session/context ID in a cookie and map everything back at the beginning of the response loop, instead of those goofy URLs. Usually URLs like that are used only as a fallback if cookies aren't enabled.

I guess I could write the entire thing as direct actions, store my own session info by user ID in the application, and go from there. Seems to me that I'd be losing a good deal of the benefits of using the framework in the first place, though.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New DirectActions
What you could do is write *one* direct action that pulls out your own sessionId from the cookie, then forwards the request to the right session - basically taking over Application's job of looking up the session in the direct action. Certainly doable.

I tend to only keep a session for a logical unit of work/transaction. So you start with a direct action - pick what you want to do - use the session to manage state while you build up your unit of work, on commit I return a directAction which essentially abandons their old session (you can call sesssion terminate to kill it right away) and gets them out of stateful mode. This seems to work the best.




I think that it's extraordinarily important that we in computer science keep fun in computing. When it started out, it was an awful lot of fun. Of course, the paying customer got shafted every now and then, and after a while we began to take their complaints seriously. We began to feel as if we really were responsible for the successful, error-free perfect use of these machines. I don't think we are. I think we're responsible for stretching them, setting them off in new directions, and keeping fun in the house. I hope the field of computer science never loses its sense of fun. Above all, I hope we don't become missionaries. Don't feel as if you're Bible salesmen. The world has too many of those already. What you know about computing other people will learn. Don't feel as if the key to successful computing is only in your hands. What's in your hands, I think and hope, is intelligence: the ability to see the machine as more than when you were first led up to it, that you can make it more.

--Alan Perlis
Expand Edited by tuberculosis Aug. 21, 2007, 05:39:54 AM EDT
New That makes more sense.
Thanks.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     WebObjects questions - (admin) - (4)
         WebObjects Answers - (tuberculosis) - (3)
             Re: WebObjects Answers - (admin) - (2)
                 DirectActions - (tuberculosis) - (1)
                     That makes more sense. - (admin)

If lies were cars, she'd be the Santa Monica Freeway at 5:30 p.m.
81 ms