(Spring) JSP -> Scalate

57 views
Skip to first unread message

logemann

unread,
Jul 6, 2011, 9:11:19 AM7/6/11
to Scalate
Hi,

currently i am developing projects with Spring MVC 3 and JSP. I am
developing JSP since years and i know this beast a lot without much
love involved lately. So the scalate thingy popped into my mind. But i
have a few questions before i really start trying to implment it.

1) Is there a spring integration for Scalate views?
2) is there something like what sitemesh does? I want to have layout
without the inlcuding hell of "tiles"
3) for a jsp developer, mustache seems to be the best thing to start
with scalate right?

Thanks for infos and thanks for your efforts to bring another level of
templating into the JVM world.

Marc

Tristan Burch

unread,
Jul 6, 2011, 12:38:08 PM7/6/11
to sca...@googlegroups.com
HI Marc,

I've been doing mixed development with Scalate, JSP, and Spring-mvc 3 for a few months and it works pretty well. To answer your questions:
  1. See http://scalate.fusesource.org/documentation/spring-mvc.html
  2. I've been using layouts to accomplish this
  3. I'd use SSP instead of mustache if you're coming from JSP. The more I've worked with scalate, the more I like using jade because I have to write less code. :) Mustache works well if you have HTML that needs to be rendered clientside and serverside but your somewhat limited by the lack of logic in the templates.
-Tristan

Stefan Ollinger

unread,
Jul 7, 2011, 8:57:33 AM7/7/11
to sca...@googlegroups.com
Hi,

what about Spring's JSP Tag Libraries, can you access those somehow from scalate's templates?

I think those 2 are relevant:

- http://static.springsource.org/spring/docs/3.0.x/reference/spring.tld.html
- http://static.springsource.org/spring/docs/3.0.x/reference/spring-form.tld.html

Regards,
Stefan

James Strachan

unread,
Jul 7, 2011, 9:31:02 AM7/7/11
to sca...@googlegroups.com
No, not right now. We'd need to write a few functions (in Java or
Scala) to match the tags - one function per tag.

--
James
-------
FuseSource
Email: ja...@fusesource.com
Web: http://fusesource.com
Twitter: jstrachan, fusenews
Blog: http://macstrac.blogspot.com/

Open Source Integration and Messaging

Tim

unread,
Jul 7, 2011, 10:31:43 AM7/7/11
to sca...@googlegroups.com
Out of curiousity James. Why not just support jsps? I guess it would almost be like the java/scala interaction problem in a way where you have to decide if you want to evaluate the java code or the scala code first but it would definitely help with the adoption of scalate since there are a ton of mature (if not always good ;)) taglib libraries out there.
Is there something technically impossible about this that I don't understand? (very possible)

Hiram Chirino

unread,
Jul 7, 2011, 10:37:12 AM7/7/11
to sca...@googlegroups.com
The question is if you want to use taglibs and jsp, why not just use
standard jsp?

Regards,
Hiram

FuseSource
Web: http://fusesource.com/

James Strachan

unread,
Jul 7, 2011, 10:57:37 AM7/7/11
to sca...@googlegroups.com
Its a nice idea - it'd certainly help folks migrating from JSP - which
must be a good thing :)

The reason we've not really done it yet is just the case that JSP tag
library implementations are generally a bit complex and totally depend
on the JSP APIs and so forth. Am not sure how easy it'd be to support
them perfectly out of the box; particularly as some of them assume JSP
EL stuff etc.

But I guess we could create some kinda JSP abstraction library, where
to a JSP tag Scalate pretended to be a JSP page and just exposed the
same JSP API; not sure how easy/hard it'd be though.

Using the JspTag classes written in Java code (or compiled to bytecode
via tag fragments) is probably not that hard I guess; we just need to
figure out how to call the Jsp tag construct and hide it behind a
Java/Scala tag function or something? Though often the JSP tags don't
do that much really; they are often fairly simple things - I can't
help think just writing those functions nicely in Scala would be more
productive & result in smaller code with less dependencies than
adapting JSP code into Scalate; but its worth an experiment if someone
fancies it?

It might be someone could start hacking little facades around some
useful libraries if we had a basic way to call a tag. e.g.

object MyFormLib {

def form(action: String, method: String = "POST) = {
callTag(new SomeFormTag(), Map("action" -> action, "method" -> method)
}

protected def callTag(tag: JspTag, args: Map[String,Any]) {
// call the JSP contract here depending on a JSP SimpleTag /
IterationTag / BodyTag etc)
}

}

we could maybe even add a generic method to call a JSP tag; given a
namespace & tag name - we'd just need a way to discover the tag
classes.

We'd just need to create a Scalate implementation of JspContext,
JspFragment, BodyContent et al. We'd maybe feel a bit dirty doing it,
but it'd maybe not be that hard?

Tristan Burch

unread,
Jul 7, 2011, 11:27:47 AM7/7/11
to sca...@googlegroups.com
I'd love to see a way to support JSP taglibs in Scalate. Losing the ability to use Spring taglibs was the biggest downside when I started using Scalate (and is still the reason I have a few JSP views).

-Tristan

Marc Logemann

unread,
Jul 7, 2011, 12:27:20 PM7/7/11
to sca...@googlegroups.com
thanks for all your hints and the ongoing discussion. Taglibs support
is cruical for getting java developers currently using Spring MVC or
the likes...

--
regards
Marc Logemann

Reply all
Reply to author
Forward
0 new messages