I would like to call java function in xsl to get logged in user. I see in the theme-examples.xsl you use the namespace version pointing to java class and then call the function. What class and function would be called to access the xxforms:get-remote-user() function? Or is there a different class and function I should be using? Thanks
Brian Steuhl
BTMSoftwareSolutions.com
|
I unpackaged the orbeon.jar file and located class file which when decompiled has getRemoteUser() method. Why doesn't this work in my xsl file?
xmlns:remoteUser="java:org.orbeon.oxf.externalcontext.ExternalContextToHttpServletRequestWrapper" <xsl:variable name="remoteUser" select="remoteUser:getRemoteUser()" as="xs:string"/> <xsl:value-of select="$remoteUser" /> I keep getting: Error at line 33, column 86 of oxf:/config/theme-examples.xsl: XPath syntax error at char 26 on line 33 in {remoteUser:getRemoteUser()}: Cannot find a matching 0-argument function named {java:org.orbeon.oxf.externalcontext.ExternalContextToHttpServletRequestWrapper}getRemoteUser() Thanks. |
Administrator
|
Brian,
xxforms:get-remote-user() is a function we specifically expose to the XForms engine. It is not available to the XSLT processor. Here is some Saxon documentation on calling Java: http://www.saxonica.com/documentation9.1/extensibility/functions.html It's fairly easy to call static methods, but a pain to create objects and call non-static methods on objects. Also, ExternalContextToHttpServletRequestWrapper is not the right place to get the remote user from XSLT. StaticExternalContext.getStaticContext().getExternalContext().getRequest().getRemoteUser() would be it. Note that for security reasons, calling Java functions from XSLT only works when the oxf:unsafe-xslt processor is used. By default, page models/page views use oxf:xslt, which is the "safe" version with calls to external functions disabled. BTW you don't need to decompile, you can just get the source from github ;) http://github.com/orbeon/orbeon-forms/ -Erik On Wed, Mar 23, 2011 at 4:10 PM, bsteuhl <[hidden email]> wrote: > I unpackaged the orbeon.jar file and located class file which when decompiled > has getRemoteUser() method. Why doesn't this work in my xsl file? > > > xmlns:remoteUser="java:org.orbeon.oxf.externalcontext.ExternalContextToHttpServletRequestWrapper" > > > > > > I keep getting: > > Error at line 33, column 86 of oxf:/config/theme-examples.xsl: > XPath syntax error at char 26 on line 33 in {remoteUser:getRemoteUser()}: > Cannot find a matching 0-argument function named > {java:org.orbeon.oxf.externalcontext.ExternalContextToHttpServletRequestWrapper}getRemoteUser() > > Thanks. > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Java-in-XSL-tp3400438p3401077.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |