. .

st4u

ST 4U 113: Building Our First Component in Seaside

July 29, 2011 7:37:14.523

Today's Smalltalk 4 You continues the VA Smalltalk Seaside tutorial with the first visual component for the blog server application. You can download the initial domain model as a file out here. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Seaside Component.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll start building the first component that will make up the main entry point for our Seaside application. Before we can get started, we need to create an open edition of our application:

Create an Open Edition

Once you've done that, you'll see that the latest edition has a timestamp rather than a version - that shows that it's open (i.e., it can be modified):

Open Edition

Next, we'll create a new subclass of WAComponent, and call it BlogServerView. This class needs two instance variables - listComponent and menuComponent. We'll set up the #initialize method to work with two additional components that we'll also create - BlogListView and BlogMenuView. Seaside uses component based assembly, so we proceed as follows: create a container view, which in turn will hold references to all the views that need to render within it.

Domain Classes

The #initialize method looks like this:


initialize
	"set up our basic components"

	super initialize.
	listComponent := BlogListView new.
	menuComponent := BlogMenuView new.

At this point, you should also have defined two other subclasses of WAComponent - BlogListView and BlogMenuView. The first of these (BlogListView) needs one instance variable, entries. With that all done, we can get to the rendering part - #renderContentOn: in BlogServerView:

Rendering

That code looks like this:


renderContentOn: html
	html heading: 'Simple Blog Server'.

	html div
		class: 'menu';
		id: 'menuid';
		with:  self menuComponent.

	html div
		class: 'list';
		id: 'listid';
		with:  self listComponent.

We need one more method - typically an #initialize method on the class side of the main view class. In this case, we'll add it to BlogServerView, and then execute the comment:


initialize
	"BlogRootUI initialize"

     WAAdmin
          register: self
          asApplicationAt: 'blogView'.

With that done, bring up a web browser and navigate to the port you are running the server on (8080 if you took the default):

Browse Seaside

Notice the new link to blogView? Click that, and you should see the following:

Rendering

That wraps it up for now. In the next section, we'll take a look at building out the sub-components

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

Enclosures:
[st4u113-iPhone.m4v ( Size: 5996855 )]

 Share Tweet This

smalltalk

The Method That is the Bane of my Work Life

July 30, 2011 15:34:49.627

I must have spent more time in the method #moveEditVerticallyBy: (in DatasetView) over the last decade than anywhere else. Just today, I was notcing a problem in the keyboard navigation in one of our datasets - and the reason is this bit of code at the bottom of the method:


	nextIndex == #changedIndex ifTrue: [^true].
	self editAt: nextIndex downcast: false.
	self triggerEvent: #cellGettingFocus.
	self topComponent keyboardProcessor currentConsumer: editor widget controller.
	^true

Note what's not there: a #valueChange sent to the controller. Without that, you get the bizarreness of the UI looking like it's selected, but the system doesn't actually register it as selected.

Now, that's in VW 7.6. In the latest release (7.8), this is fixed. Unfortunately, I'm not working in 7.8....

Technorati Tags:

 Share Tweet This

podcasting

IM Hiatus This Weekend

July 30, 2011 18:07:02.664

The podcast will be in hiatus this weekend - I've been pretty busy, and haven't had time to put anything together. We'll be back next weekend with a new episode.

Technorati Tags:

 Share Tweet This

PR

Does Paul Graham Understand PR?

July 30, 2011 21:42:50.000

A while back, Airbnb (a "rent your home to strangers" service) had a nasty incident where some grifters took advantage of a user of the system and robbed her blind. I read about that on TechCrunch - and they asked Airbnb what they were going to do for the customer. When he got an equivocal answer, he said the understandable thing: they weren't guaranteeing any compensation at all. To which Graham responded:

The story Arrington wrote yesterday about Airbnb not offering to help was bullshit. He asked a company spokesman what Airbnb was doing to help her. The spokesman, who’d been told by their lawyers that he couldn’t go into detail about that because of the precedent said “I can’t comment on that.” So Arrington, in typical Arrington fashion said “Well, unless you tell me I’m going to write that you’re not willing to do anything for her.” And he did. Really not cool. I’ve talked to the Airbnb guys and they are already doing everything they could be doing to help this woman.

Well. I can only assume that Graham hasn't even heard of PR. When something bad happens to a customer, and the PR staff are only willing to come back with blather, what the heck does he expect?

 Share Tweet This

books

Griftopia

July 31, 2011 18:33:00.674

I just finished reading Griftopia - a fascinating look at the financial and political situation of the US after the 2008 crisis by Matt Taibbi. It's not an objective book, but if you take that into account, it's a very well written look at what happened (and more importantly, why it happened).

I've read pretty widely on this subject, and I think this book is one of the few I've read that really tries to look under the hood, as it were. If you want an unsparing examination of what's gone wrong, this is one book you should definitely look at.

One small caveat - if you're bothered by profanity, this book may not be for you. It's laced with it - in some ways, it reads more like a conversation than like typical prose. If you can get past that, it's worth a look. Also, check your ideology at the door. While my worldview and Taibbi's are pretty far apart, he doesn't spare anyone (or any party) in this book.

Technorati Tags:

 Share Tweet This

smalltalk

Deploying Smalltalk Apps

August 1, 2011 8:19:35.654

I've done a fair bit of posting (and screencasting) on this topic for VW - Torsten has covered the bases for Squeak and Pharo in a very impressive way.

Technorati Tags: , ,

 Share Tweet This

st4u

ST 4U 114: Code Recovery in Pharo

August 1, 2011 10:23:42.844

Today's Smalltalk 4 You looks at code recovery using Pharo. Sometimes, you lose an image (crash, inadvertant quit without saving, power outage...) - and you really don't want to lose whatever code you've been working on. Today we'll look at how to recover your work using tools built into Pharo. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Code Recovery

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: , ,

Enclosures:
[st4u114-iPhone.m4v ( Size: 4317416 )]

 Share Tweet This

smalltalk

Seaside Sprint After ESUG

August 1, 2011 16:57:39.278

The VMWare (Gemstone) folks are sponsoring a post-ESUG Seaside sprint:

The fine folks at VMware (formerly GemStone) are so kind to pay for the venue of the Seaside Sprint after ESUG in Edinburgh.

Technorati Tags: ,

 Share Tweet This

search

Fun With Searching

August 2, 2011 8:07:19.204

I wonder whether Google has any edge cases like this one John Forsyth found in Bing?

At first I thought it was a problem with the URL I was searching for, but it turns out any search containing the words "view topic" will crash Bing.

See for yourself, with one of the examples he posted (Follow the link above for more):

"what topics do they discuss on The View?"

It turns out that Bing is filtering out searches for phpBB that involve viewtopic.php (a huge security problem, seemingly) - and a bunch of other searches are merely collateral damage. Go read the whole story - it's fascinating stuff.

 Share Tweet This

smalltalk

More Pharo Documentation

August 2, 2011 8:40:20.000

Stef Ducasse has written two more chapters of Pharo documentation.

Technorati Tags: ,

 Share Tweet This

js4u

JS 4U 78: SlideUp with JQuery

August 2, 2011 8:56:42.204

Javascript 4 U

Today's Javascript 4 You. Today we look at the slideUp() function in JQuery. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

slideUp()

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: , ,

Enclosures:
[js4u78-iPhone.m4v ( Size: 1814303 )]

 Share Tweet This

st4u

ST 4U 115: Rendering Components

August 3, 2011 9:40:51.501

Today's Smalltalk 4 You continues the VA Smalltalk Seaside tutorial with the addition of rendering for individual post. You can download the initial domain model as a file out here. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Seaside Component.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll continue building our Seaside blog server by adding rendering for posts. First though, we need to modify our domain a bit: add the following class method to BlogPost, BlogStorage, and BlogUser:


new
	^super new initialize

That will ensure that our initialize method gets invoked on instance creation. Next, add the following method to BlogLIstView:


renderContentOn: html
	"standard way to render a component in Seaside"

	| posts |
	posts := BlogStorage default posts.
	posts do: [:each |
		each renderPost: each on: html].

What that does is delegate the task of rendering off to the post object. That's a good idea, as each post may have differences - attached audio/video, etc. That means we need to add this method to BlogPost:


renderPost: post on: html

	html div
		class: 'post';
		with: [html paragraph: [
			html strong: [html text: post title].
			html break.
			html html: post content.
			html break.
			html text: 'Posted on: ', post timestamp printString.
			html break]].

Note the way rendering works - it's a lot like the way we build a UI using general UI building tools. Each component renders itself on the canvas, and the placement is handled by CSS (it's easy to attach CSS, either in the image or in an external file - we'll cover that later). Now we need to run a script to create some blog posts, as we haven't created an editor yet. Open up a workspace, and execute the following:


BlogStorage default.


user := BlogUser new.
user id: 1.
user username: 'fred'.
user password: 'flintstone'.
BlogStorage default users add: user.

post := BlogPost new.
post title: 'This is a Test'.
post content: '

How will this work out?

'. post owner: user. BlogStorage default posts add: post. post2 := BlogPost new. post2 title: 'Old Stuff'. post2 content: '

This should be yesterday

'. post2 owner: user. post2 timestamp: (AbtTimestamp date: (Date today subtractDays: 1) time: Time now). post2 id: post2 timestamp totalSeconds. BlogStorage default posts add: post2.

That creates two posts objects, one from yesterday. As you look at this, you'll note that we aren't sorting the posts for display using reverse chronological order - we'll leave that as an exercise for the reader :)

With that done, refresh the browser, and you should see this:

Posts

That wraps it up for now.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Enclosures:
[st4u115-iPhone.m4v ( Size: 7250488 )]

 Share Tweet This

social media

The Founders Would Not Be Amused

August 3, 2011 9:50:14.051

The guys at Facebook have a grasp of history that stretches back, oh, maybe 15 minutes. Here they are on anonymity:

I think anonymity on the Internet has to go away. People behave a lot better when they have their real names down. … I think people hide behind anonymity and they feel like they can say whatever they want behind closed doors.

Maybe these guys should have a look at the credited authors of the "Federalist Papers" - oh, wait - they were anonymous. Or perhaps at Ben Franklin's work during the same era - published anonymously. While I usually prefer that people attach their names to comments, it's not always the best policy. When the "consensus answer" on a question is X, and you think Y, it can be safer to push your ideas behind a veil of anonymity. One size does not fit all here.

 Share Tweet This

smalltalk

Pharo and OCR

August 3, 2011 15:57:47.321

Torsten reports on more interesting Pharo work from Pinesoft:

Gary Chambers (creator of the Polymorph UI framework for Pharo) is currently building an image capture, OCR and data processing system using Smalltalk and he provides a first screenshot.

Technorati Tags: ,

 Share Tweet This

games

Game Graphics Boost?

August 3, 2011 20:41:28.745

If this Euclidean technology demo holds up, games are about to get a lot cooler looking.

Technorati Tags:

 Share Tweet This

smalltalk

Pharo by Example in Spanish

August 4, 2011 6:17:24.555

Torsten Reports that Pharo by Example is now available in Spanish:

The book Pharo by Example is now translated into Spanish too.

Technorati Tags:

 Share Tweet This

itNews

Much Ado About Very Little

August 4, 2011 7:16:35.780

I see that a (supposed) public interest group is upset over data caps in the 4g world (never mind that they also exist in 3g):

"Activities that are made possible by 4G, such as watching movies or uploading video to the internet, are made impossible by the data caps," wrote the report's author, Michael Weinberg.

Well - I can certainly speak to that, as I use tethering on my iPhone quite a bit. As most of you know, I travel to Texas on a regular basis for work, and the class of hotel I'm staying is often, shall we say, bandwidth challenged. Quite frequently, I use my iPhone instead of the hotel wifi to upload my daily screencasts, and I haven't come close to going over the bandwidth cap. Heck, I've downloaded a bit over 5gb since July 2010, using the 3g network pretty heavily.

I'm not sure what the alternative is - making it all unlimited and "free" is likely to lead to a tragedy of the commons situation. Like it or not, the airwaves are a much more constrained resource than, say, a fiber optic line. We'll end up paying for usage one way or another, either directly via tiered usage plans, or indirectly via rationing. There's no magic bandwidth fairy out there who can create more spectrum.

Technorati Tags: , ,

 Share Tweet This

js4u

JS 4U 79: Toggling Slide Animation

August 4, 2011 7:51:45.840

Javascript 4 U

Today's Javascript 4 You. Today we look at the slideToggle() function in JQuery. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

slideToggle()

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: , ,

Enclosures:
[js4u79-iPhone.m4v ( Size: 2325141 )]

 Share Tweet This

smalltalk

A SmallHarbour Blog in One Minute

August 4, 2011 19:04:56.181

This looks pretty cool:

Create a blog easily with SmallHArbour from Romain Verduci on Vimeo.

Technorati Tags: , ,

 Share Tweet This

smalltalk

Lost in a Dependency Maze

August 4, 2011 22:25:24.146

I'd like to use Squeak and Pharo more often, but then I run into problems like this:

  • Spot a post promoting something like the MongoDB interface
  • Go to the Project page
  • Try to figure out what to load in what order
  • After a few minutes of thrashing, give up

This is one area that the commercial vendors - Cincom and Instantiations - are way, way ahead in. If you load something that has pre-reqs, it's likely that the pre-reqs are set, and that they'll load automatically. Using Gofer with Pharo (for projects that have a configuration), that's also true. In Squeak? It's still a huge problem.

 Share Tweet This

st4u

ST 4U 116: Adding the Menu Component

August 5, 2011 9:20:56.093

Today's Smalltalk 4 You continues the VA Smalltalk Seaside tutorial with the addition of the menu component (a set of filtering links in this example). You can download the initial domain model as a file out here. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Seaside Component.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


In this section of the tutorial, we're going to get the menu component working. Along the way, we'll also learn about the important #children method, which should report back all the (non call'd) components that a Seaside UI will display. So let's get started with BlogMenuView. First, you'll need to modify the #initialize method:


initialize
	super initialize.
	entries := OrderedCollection new

It will become apparent in a few minutes why that variable needs to be a collection. To set the menu options, we'll go back to class BlogServerView and flesh out the initialization of the menu component. We'll modify the #initialize method, and add #initializeMenuComponent, as shown below:


initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	listComponent := BlogListView new.
	self initializeMenuComponent.


initializeMenuComponent
	menuComponent := BlogMenuView new.
	menuComponent addEntry: 'All Posts' withAction: [self allPosts].
	menuComponent addEntry: 'Today''s Posts' withAction: [self todaysPosts].

While you accepted that method, you'll notice that a number of the message references are red; that's because we are creating forward . First, let's create the one being called in BlogMenuView - #addEntry:withAction:


addEntry: label withAction: actionBlock

	self entries add: label -> actionBlock

What this does is create an Association object (a key/value pair) which is stored in the collection. We'll then render a set of urls using those entries. To do that, add this rendering method to BlogMenuView:


renderContentOn: html

	self entries do: [:each |
		html anchor
			callback: each value;
			with: each key]
		separatedBy: [html space]

We aren't quite ready yet - we have some menu options for filtering, but we have not specified the filtering code yet! So, we need to add an instance variable to class BlogListView called filterBlock, and add accessing methods for it, as shown below:

adding filters

Now, add the following methods to BlogListView


filterBlock
	^filterBlock

filterBlock: anObject
	filterBlock := anObject


setAllPostsFilter
	filterBlock := [Storage default posts]

setTodaysPostsFilter
	filterBlock := [Storage default posts select: [:each | each timestamp asDate = Date today ]]

Finally, we need to modify the #initialize method in BlogListView


initialize
	"set up the initial filter"

	super initialize.
	self setAllPostsFilter

Back in class BlogServerView, we left a reference to the methods we just created - so now we'll hook that up, and add the #children method mentioned back at the top of this section:


allPosts
	listComponent setAllPostsFilter

todaysPosts
	listComponent setTodaysPostsFilter

children
	^Array with: listComponent with: menuComponent

When we run that (using the Seaside menu, launch the application in the browser), it should almost work - you'll see the menu options, but selecting them has no visible effect. That's because we have not updated the rendering code in BlogListView. Make the #renderContentOn: method in that class use the current filter:


renderContentOn: html
	| posts |
	posts := self filterBlock value.
	posts do: [:each |
		self renderPost: each on: html]

It should do the right thing now! That's as far as we'll go in this section. Next, we'll look at custom sessions.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , , ,

Enclosures:
[st4u116-iPhone.m4v ( Size: 7969139 )]

 Share Tweet This

games

Better Inventory System for Skyrim?

August 5, 2011 9:29:54.443

This is a game I'm really looking forward to - and it sounds like some real thought has gone into the chokepoints of its predecessors:

"RPGs send you into menus more than almost any other game genre, so it's weird that more thought doesn't go into inventory design, but as I play around with powers, weapons and items to lighten my load it becomes clear that Skyrim is a welcome exception. Its nested menus are accessed almost as smoothly as iPad page swipes, and navigating them is quick and clean. You can set favorites, equip items to either hand, and examine things in detail. More than once during my brief hands-on I have to rotate an object to look for a clue to a puzzle, or read a document, and it's all done without going to a different screen or do anything more complex than wiggling sticks and hitting a face button. It's easy to imagine that a system like this in Oblivion or Fallout could have shaved hours off the average player's actual game-time.

I'm playing Oblivion now, and yes - you spend a lot of time in the inventory screens....

Technorati Tags: ,

 Share Tweet This

smalltalk

GUI Tools for GST

August 5, 2011 15:38:18.000

There's an announcement for new GUI tools for GNU Smalltalk. Sounds like early days, but there's code to play with, and a screencast:

I am working on an IDE for GNU Smalltalk from time to time. It is called Overlord and it is a simple and classic class browser like gst-blox (so nothing new). It has come to a stage where it might have its usage for some people.
Besides the very very ugly coding, it lacks some major features like exporting capability, debugger and inspector. Also its text editor is just a text view for now... But you can do simple things like adding/editing/removing namespaces, classes, methods and it has syntax highlighting.

Technorati Tags: ,

 Share Tweet This

general

Prompt Service

August 5, 2011 21:00:04.000

I was reading an article by Jeff Jarvis, in which he posits the "jobless future" due to automation. This passage, for instance:

Take retail. Borders. Circuit City. Sharper Image. KB Toys. CompUSA. Dead. Every main street and every mall has empty stores that are not going to be filled. Buying things locally for immediate gratification will be a premium service because it is far more efficient — in terms of inventory cost, real estate, staffing — to consolidate and fulfill merchandise at a distance. Wal-Mart isn’t killing retailing. Amazon is. Transparent pricing online will reduce prices and profitability yet more. Retail will be more efficient.

That came to mind because the USB hub I ordered on Amazon - a replacement for the one that up and died yesterday - arrived a few minutes ago. Making do with an ancient 4 port hub for less than 24 hours was a lot simpler than heading out to Best Buy, which is what Jeff is partly on about.

His larger point is just wrong though - consider agriculture. Over the last 200 years, that's gone from a field employing nearly all people to one that employs very few, while also growing more. Did that lead to a huge problem of idle hands? The problem is simpler: the current crop of elites we have in this country (and, I think all over the world, really), is simply not ready for the future. They are desperately trying to regulate the status quo back into existence, and all they are accomplishing is stagnation. Back when the revolution of automation hit agriculture, governments mostly stood aside, and it all worked out (yes, with many bumps and problems along the way).

What we face now isn't a jobless future; it's a complete lack of useful governing elites, right across the political spectrum. They really, really don't know what they don't know.

Technorati Tags:

 Share Tweet This

smalltalk

Smalltalk Appreciation

August 5, 2011 21:05:53.793

 Share Tweet This