[stringtemplate-interest] Multimethods

Harry Karadimas harry.karadimas at hmn.aphp.fr
Wed Nov 12 06:24:28 PST 2008


Yes, except for one little nasty requirement of Java Servlets : session
encoding
as a path parameter. If a user turns cookies off (which happens in our
hospital, rather by mistake, but our mission - critical sites must
continue to function), the Servlet container must append an url
path parameter (which is different from a request parameter) named
jsession_id. The requirement for java servlets is that every URL
must be coded using response.encodeURL(String url). 

(see
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpServlet
Response.html#encodeURL(java.lang.String)
)

That, unfortunately, is computation. And by design it gets very difficult
to do in st. And coding every link in the controller makes things really
too tedious for the programmers, and too restrictive for the view authors.
For the moment I cheat, by putting
the response object in a thread-local variable, and using it with a special
"url" format for strings. In this manner I can use 
<a href="$mylink;format="url"$">my link</a> but having a mechanism 
(operator or other) in st do this would be beneficial for the correct 
(= recommended by Sun) use of st in java servlets.

Best regards,

______________________________________________________________________
Dr Harry Karadimas,  Medecin Ingenieur
resp. Recherche et Developpement, Administration Wintel
Departement d'Information Hospitalier (DIH)
C.H.U. Albert Chenevier - Henri Mondor 
51, av. du Marechal de Lattre de Tassigny               94010  CRETEIL
tel : (00 33 1) 49 81 21 79                fax : (00 33 1) 49 81 27 08
secr.: (00 33 1) 49 81 23 82         m.el.:harry.karadimas at hmn.aphp.fr

Date: Tue, 11 Nov 2008 09:39:07 -0800
From: Terence Parr <parrt at cs.usfca.edu>
Subject: Re: [stringtemplate-interest] Multimethods
To: Roman Odaisky <roma at qwertty.com>
Cc: stringtemplate-interest at antlr.org
Message-ID: <6857A206-DB76-44B8-A435-D21459A05ECF at cs.usfca.edu>
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
	delsp=yes


On Nov 10, 2008, at 10:46 PM, Roman Odaisky wrote:

> On Monday, 10.11.2008 19:34:33 Terence Parr wrote:
>
>> Is there a string you can pass to a renderer that can be broken apart 
>> to compute the proper URL? If the URL is truly computation, then it 
>> must be a part of the controller; the controller does the mapping of 
>> URL to executable code. This is case, then it would violate MVC 
>> separation to compute URLs in the view.
>
> I need a way to say, ?Here I need a link to a page that would refer to 
> X and Y?. Something like <a href="$blog_posts(y=2008, m=2, d=8)$"> 
> that would result in .../2008/02/08/... or .../2008-02-08/... or 
> something else depending on configuration.
>
>
> To me this looks very declarative and not violating anything.

Yep, unless you compute.  That should work if blog_posts can just paste things
together.  if it computes or has logic, must be in controller.

Ter

------------------------------

_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest


End of stringtemplate-interest Digest, Vol 44, Issue 2
******************************************************



More information about the stringtemplate-interest mailing list