Home
TeamSite
Preview in XSLT
Parag
Hi,
I hope some would have answer to how to determine Preview and Generate activity in XSLT.
Our presentation templates are in XSLT. In template I want to execute a condition only if the user is generating a output page and not during Preview, how can I check it?
Thanks,
-Parag
TeamSite 7.2.1 on Win2K8 Server.
Find more posts tagged with
Comments
Bowker
I asked a similar question and got crickets for a response...
This is how we do it.
1) We have built a controller that returns a number of things about the request including (there's more):
host name -java.new.InetAddress.getLocalHost().getHostName().toLowerCase()
mode - context.getMode().toString()
environment (determined by a look-up on host name)
lscs - the host name for this server's LSCS server (we have multiple)
all passed parameters on the URL
browser header information
any "site wide parameters" we want passed from the Site parameters
2) Then in the XSL receive them as /Properties/Data/Result/....
***WARNING***
If you do this be careful of caching. I don't know if Preview mode and Generate mode share a LSDS RunTime cache or not, but if it does, you will have issues with this.
Also - in our case, as soon as the XSL uses any of the "Parameters Passed on the URL" stuff, the component CAN NOT be cached.
*** You have been warned ***
Migrateduser
To simplify what was said above, you can just look at the requestContext in a Java prefix/external for a component, and add "isRuntime" as part of the response.
What I would do is write a universal prefix that pushes out any request info you may need to the component data so the XSL can run on it.
If you need more help or clarification, let me know.
Parag
Hi ehibbs,
Actually I am not using the Sitepublisher so the components/externals will not come in picture. The templates are simple XSLTs.
In case of perl templates (.tpls) there were ways to check whether the current action is preview or generation, I am looking for the same.
Thanks,
-Parag
Rick Poulin
I don't believe the XSLT route gets passed environment variables the way TPLs do, not that you'd have access to them anyway. You could try
1- Use a hidden field in the DCR, populate as a result of onPreview and onGenerate events.
2- Assuming the XSL *does* get passed env vars, you could perhaps use a Java extension call java.lang.System.getenv('varname'), though that's a static method so you probably need to wrap it in a class of your own.. maybe.
Adam Stoller
I cannot validate any of these, but there are a number of threads that already exist regarding this: