Effective October 27, 2012, online and email support for FuseSource products will move to Red Hat support channels. For more information, please see the JIRA Migration to Red Hat FAQ.
As of October 27th, please open all new issues in the Red Hat Customer Portal .
Issue Details (XML | Word | Printable)

Key: SCALATE-28
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: James Strachan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Forge: Scalate

support the mapping of an XML element to a function

Created: 09/Feb/10 12:18 PM   Updated: 26/Mar/10 01:07 PM
Component/s: scalate-core
Affects Version/s: None
Fix Version/s: Someday

Issue Links:
Linked
 


 Description  « Hide
It might be nice to support custom tags using XML markup notation as well.

This came up on this thread...
http://old.nabble.com/Re%3A-JSP-taglibs-in-Scala-p27514294.html

<html xmlns:foo="scala:org.acme.MyTags"> 
 ... 
 <foo:cheese blah="123"> 
   ... 
   ${something} 
   ... 
 </foo:cheese> 
</html>

which would translate to the equivalent of this...

<html>
<% import org.acme.MyTags._ %> 
 ... 
 <%= cheese(blah="123")  { %> 
   ... 
   ${something} 
   ... 
 <% } %>
</html>


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Erkki Lindpere added a comment - 09/Feb/10 08:05 PM
Would this work with singletons only? It would be nice if it also worked with default constructors of classes, then I could trigger dependency injection manually in the constructor (I think at least Guice allows that, but I haven't tried).

Or maybe the uri scheme could be pluggable, for example "guice:org.acme.MyTags" and I could extend Scalate with a Guice provider. Or Spring etc.


James Strachan added a comment - 09/Feb/10 08:13 PM
interesting idea! Using JAXRS controllers with things like Jersey works like this. It makes total sense to support IoC in the same way too.

Initially I was thinking the namespace would basically just map to an import; so the "org.acme.MyTags" just basically does...

import org.acme.MyTags._

but maybe we need to support instantiation of a tag library as a variable; then instantiate that. So something like this...

val myTagLib = injector.createInstance(classOf[org.acme.MyTags])
import myTagLib._

Maybe we need a slight different namespace URI to differentiate against the IoC created instance versus the straight import.

maybe something like this...

<html xmlns:foo="import:org.acme.MyTags._"> ...

where the import is basically in the namespace URI so that you could exclude some imports or rename methods etc.

Then we have explicit injection of a type...

<html xmlns:foo="inject:com.acme.Foo"> ...