3
votes

I would like to include some results from client side JavaScript (csjs) into my server side JavaScript (ssjs) in XPages.

e.g. on csjs i collect the screenwidth of a device via window.screen.availWidth

I would like to use the result further in my ssjs. How can I do this?

2

2 Answers

2
votes

You need to send the screen width and height from you client script to you server script.

using QueryString (location.href=...../?open&width=xxxx&height=yyyyy), setting a field on your xpage and to a partialrefresh or using extlib remote service.

There are probably several more ways of doing it ;-)

1
votes

Another approach could be, you could put your result of CSJS calculation in a hidden input field and then get those values in your SSJS code.

Also you can look into this discussion in StackOverflow for some more ideas. It basically uses partial refresh and passes the values from CSJS as parameters.

XSP.partialRefreshPost('#{id:_element_to_refresh_}', {params: p});

You could then access those parameters in your SSJS code.

And I would be repeating Fredrik, "there are probably several more ways of doing it" ;-)