Wednesday, April 1, 2009

Question: Can XPages only be used for HTML?

The reason I'm asking is that the html/js/css code generated by your average XPage is too bloated for my taste.



I love the server side scripting/speed/pseudo-relational lookups part of the technology though.

My question: Is it possible to use XPages to generate other content than HTML, like (valid) XML and JSON, and how?

I've tried my friend Google, but he found nothing for me.

7 comments:

NotesSensei said...

XPages is a JSF application. Therefore the "raw" XPage is transformed by a renderer into the stuff that is sent down the wire.
You have 2 options:
- Use XPages in "agent mode" (see my blog)
- write your own renderer

The renderer would be the better choice, but it isn't documented (yet).
You can talk to the Xpages team what exactly you would expect. There are new versions in the pipeline

Unknown said...

Wrong link. It's here:
http://www.wissel.net/blog/d6plinks/SHWL-7MGFBN

Jan Schulz said...

I would also have valid HTML and JS, which follows best practise (like using AJAX thingies, but also normal links to server side generated content for non JS Users). In this form it is nice for internal websites, where you have a certain browser, but not for external ones, where you get the whole bunch of browsers.

Tommy Valand said...

@NotesSensei: Writing my own renderer would take way (way way) too much time, considering my Java skills.

I'm not exactly sure myself how I would generate XML/JSON from a regular XPage in an easy way. It probably would have to include a repeat-control.

I'll try out the XPage-agent method. Thanks!

@Klehmann: Deleted my initial comment, and fixed the link. Thanks for letting me know.

@Jan: Couldn't agree more. I found no way of setting the DOCTYPE of an XPage, or of generating an empty XPage (no markup).

It would be great to use the view-control or the repeat control without having to import XX stylesheets and javascript libraries.

Nate said...

Tommy, the "Xpages-agent" method works really, really well. It's fast. It's crazy fast.

The render kit approach is likely even faster, but the Xpages team isn't ready to support that level of flexibility yet. Use Stephan's approach in the meantime -- you won't be sorry.

Bjørn Cintra said...

Hi

I just stumbled across this post, and wanted to mention (shameless self promotion) that http://www.hamaroy.kommune.no/tjenester that goes live tomorrow (29/06/2009) is using an Xpage with the "agent mode", calling a LotusScript webservice that renders a page based on a template.
For most of the application, I'm using "classical" Notes approaches, but for the tjenester part I'm using an XPage, mostly for the URL's.

Tommy Valand said...

@Bjorn: Seing as you're not promoting Viagra or Cialis, I'll let it slide.. :P