Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Entries

photo

XPages - initial cur...

Blog:  Notes from th...
Jerry Shelley
Updated 
No RatingsRatings 0     CommentsComments 4
photo

Editing mulitple dat...

Blog:  Pascal David
Pascal David
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

(struggling with) ed...

Blog:  Pascal David
Pascal David
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

Two Document Datasou...

Blog:  Notes from th...
Jerry Shelley
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

Re: XPages - Exceedi...

Blog:  Paul's Domino...
Paul Hannan
Updated 
No RatingsRatings 0     No CommentsComments 0

Bookmarks

Yellow is the New Blog

Blog Authors:  Tim Tripcony  

Previous |  Main  | Next

Quick tip: handling data posted to an XPage

Tim Tripcony  |     |  Tags:  xpages  |  Comments (1)
Stephan posted an enlightening article about treating XPages like web agents. He shows how, instead of using an XPage as a visual element, we can block Domino from rendering any markup and manually print to the browser, just like we often do now with agents... except that, since it's still an XPage, we have access to stuff like scoped variables (i.e. we can grab settings directly out memory via the applicationScope instead of having to query the database itself) and the comparative programmatic ease of SSJS. He demonstrates how to set the Content-Type and generate the HTTP response using the facesContext global variable as a starting point.

One other handy use for facesContext is that we finally have a standard way of intercepting request data for GETs and POSTs:

facesContext.getExternalContext().getRequest().getParameter( "paramName" );

Or, if you're not into the whole chaining thing:

var exCon = facesContext.getExternalContext();
var request = exCon.getRequest(); // This is the actual HTTP servlet request...
var paramValue = request.getParameter( "paramName" );

So... if the user navigates to "something.nsf/myxpage.xsp?foo=bar", passing "foo" as the paramName returns "bar". Similarly, if an Ajax request posts to "mypage.xsp" and the postData is "foo=bar", same result. In other words, the code of your XPage doesn't care: you can use the same exact method to determine the value of foo, whether it's specified in the URL query string in a GET or submitted via a POST. It just works; you don't need different code for each. Hooray.

P.S. Did you notice something bizarre about that example URL? Something just so... well, anti-Domino? That's right: no ?Open. It's not "pageName.xsp?OpenXPage&someField=someValue"... just "pageName.xsp?someField=someValue" (but, because of the way servlets parse the request, if you forget or get nostalgic, you can include your own ?Open and it'll just ignore it). Finally Domino joins every other web server at the query string syntax party... I guess it just wanted to be "fashionably late".

Comments

1 Stephan H. Wissel      Permalink Next step in deep XPages understanding:
- How to post to an XPage from an Ajax request and get the fields that are bound to controls properly saved into a backend document and get a nice reply.
:-) stw


Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.