#1121 Web templates

tcolar Thu 17 Jun 2010

Building web pages using res.out.head and the like is nice for testing stuff but as far as a "real" website goes (as in web designers involved) that doesn't really help.

That's how servlet did it originally and most agreed spitting out html from code is not the way to go, then their was JSP, which makes more sense (calling the code from the html) but got kinda ugly.

Personally I think my "favorite" way is when the HTML stays "standard" and uses place holders to call in data, as it was originally done simply in velocity, then refined in wicket, lift, sitemesh(sorta) and many other frameworks, including my own :)

Basically you just have data holders like ${user.name } or <data:userList/>

Myself I like to have the least possible "logic/code" allowed in the template, just data callbacks, this makes them more web design tool friendly and much cleaner.

Anyway without going into the whole "web framework" topic, I was wondering whether Fantom had anything like this at all, or not (not that I can see), too me that is almost a "must have" for developing a "fancy" webapp / site.

Is there anything like that, any plans ?

andy Thu 17 Jun 2010

I think there's a reason there are a zillion Java client-side web frameworks - and at the center of it, its a simple fact that really, there's not a logical "right way" to do it. Its a messy tangle of different technologies. So people build their own to suit their preferences. So that's sorta been my philosophy with Fantom as well. We have a really great low-level and clean abstraction point in the web pod - which covers alot of boilerplate code traditional frameworks are built to handle. But it doesn't dictate any mechanism for building pages intentionally.

I've found that given that the web pod is head and shoulders more complete and usable than the Servlet API - that it really becomes rather trivial to build your own mini framework to suit your style and needs for your application. And if you're tried WebOutStream - I think you'd agree its way easier for writing markup than straight HTML or a JSP-style language and trying deal with data binding.

Thats not to say there is not a place for a JSP-style system - I just believe there are too many competing factors that go into designing webapps to try and dictate a platform that the majority of developers will opt into and enjoy using. I would love to see it happen tho, so hopefully someone will prove me wrong ;) But either way I would love to see some great frameworks popup to fill this void for people who really do just want something off-the-shelf.

From the RIA standpoint - we have the FWT already so it was logical to port this to the browser - and I think this is turning out to be an awesome feature of Fantom, if you want to leverage the power of Fantom for writing JavaScript code. But even there, the core "web" piece that maps pages to URLs, deals with security, handles XHR requests, all of that is so open-ended, that I think we're better off making that kind of stuff really easy to do yourself, over trying to create a big complicated one-size-fits-all solution.

My two cents :)

tcolar Thu 17 Jun 2010

I'm not saying that stuff needs to be part of Fantom's core, actually Fantom already has much more "web" features than most language cores.

I do agree that all frameworks have their places depending of the projects, and I think FWT and the javascript code is great to build rich data apps (say something like gmail), on the other hand to do something like say an e-commerce website that might not be the best to work with (something like Lift would work best).

I guess I'll probably make my own simple web framework stuff then, I already have one made in java, so basically just have to port some of it, which should be much more compact in Fantom, since as you mentioned the "web" base is better that what java gives you ... I've tweaked it a lot over the years so I kinda like where it's at, so hopefully it should turn out nice.

Did anybody here write any such "web framework" stuff in Fantom yet ?

katox Thu 17 Jun 2010

@tcolar I think any JSP style is a clear no-go. Wicket is an exception but hey there are no additional DSLs to learn and HTML templates are ... HTML ;). But why should one create yet another mediocre "standard" web framework (even though in fantom)?

If there is energy to be spent I think it's much better spent with something like js smartclient fantom bridge (thx @dfreire for a pointer to that) or custom fwt component styling.

tcolar Thu 17 Jun 2010

You must have misunderstood me, because I hate JSP's, and I specifically said I want the pages to be Plain standard HTML with no code in them (Scala's Lift framework is probably the closest thing to what I have in mind)

I'm not saying smartclient is not cool, but look at the examples, you can see right away it's target to do "rich", data heavy sites with fairly plain static look&feel.

But now when you go to a "real" E-commerce site for example, the marketing, web-design and look and feel are what's important, and changes often and need to be easy to work with by a large team where not everybody is a web developer. It also need to work on "old" browsers btw.

Like Andy said there is a reason why there are many different frameworks, that's because the kind of application/site you do really can vary a lot and require different approaches and I don't think none is perfect.

rfeldman Thu 17 Jun 2010

To play devil's advocate, I once worked on a project where we hired a graphics designer to come up with a highly stylized, attractive UI. What he delivered to us was static HTML that made for good-looking but nonfunctional pages. (As I recall he used some authoring tool like Dreamweaver.)

In a situation like that, HTML templates are exactly what you want - you just add dynamic functionality to existing static content. Translating all that HTML by hand into something else would be a monumentally poor (not to mention error-prone) use of developers' time.

Obviously if I'm scratch-building, I wouldn't even consider a HTML template. But if I need a site that looks megatons better than what not-so-graphically-inclined-me can come up with on my own, and I've got a graphics pro who can deliver me a static page that looks fantastic, then something like JSP or Velocity is almost always the way to go.

tcolar Thu 17 Jun 2010

On my own project I like to do the HTML by hand, in part because what tools like dreamweaver generate is pretty messy - but that doesn't look very flashy usualy as you can see on my site :)

On the other hand I've worked on large websites for large companies and as far I know almost no such site page design is done by hand coding ... this would be a LOT of painful work !

cbeust Fri 18 Jun 2010

Have you considered imitating the GWT model? Fantom's native support for Javascript seems to make this approach very appealing and probably quite feasible in a reasonable amount of time...

-- Cédric

jodastephen Sat 19 Jun 2010

I'd like to see Fantom pick up some of the Ruby innovations. This is where they are way ahead of Java-land:

Sass: http://sass-lang.com/ Extensions to CSS to make it much more usable.

Compass: http://compass-style.org/docs/reference/compass/ Library of fixes to vross-browser CSS issues.

Haml: http://haml-lang.com/ Radical alternative to XML-style HTML (also usable in Sass)

For this problem in general, the Fantom DSL feature is ideal, as it allows the inserted variables and expressions to be compile time checked to some degree.

(I'd note that there are multiple ways to address templating, and the right answer may vary by project)

brian Mon 21 Jun 2010

While I think it would be great for the community to rally around one design, this is one of those areas where having lots of options seems to be ok. Although if everyone could agree on the best way to do it, that would be cool.

Although I think what we really need is the standardized centralized repository so that different solutions and pods like this are easily discovered from fantom.org. I've actually been giving that one lots of thought lately.

msl Mon 21 Jun 2010

<off topic>

Although I think what we really need is the standardized centralized repository so that different solutions and pods like this are easily discovered from fantom.org.

CFAN? :)

</off topic>

tactics Mon 21 Jun 2010

CFAN? :)

Punning off of Perl seems like a bad idea.

Perhaps instead, to play off of the name "Fantom", we can call the repository "Graveyard"... you know, since most of the projects will be left unmaintained after a year.

While I think it would be great for the community to rally around one design, this is one of those areas where having lots of options seems to be ok.

I'm reminded of Python's web framework woes. For a long time, there was no real agreement on which framework should be considered the standard (especially between Pylons and Django).

Fantom seems a little better off, since there's a standard web core. But it's something to keep in mind.

go4 Fri 25 Jun 2010

How to embed FWT in HTML. The FWT is full of browser and hide the HTML.

andy Fri 25 Jun 2010

How to embed FWT in HTML. The FWT is full of browser and hide the HTML.

See the mount.fan demo under examples/js/. Don't think that's in the latest build - so if you're not running off tip - you can see it here: mount.fan.

In your the Weblet that mounts your Window, just need to add this env var and pass to jsMain:

env := ["fwt.window.root":"fwt-root"]
WebUtil.jsMain(out, main, env)

And make sure in your HTML body you have that id somewhere:

div("id='fwt-root' style='position:relative; width:400px; height:300px;'").divEnd

go4 Mon 28 Jun 2010

Thanks!

Login or Signup to reply.