How to properly integrate Orbeon with Grails? - grails

Attempting to integrate Orbeon 3.9 CE with Grails 1.3.7, using the recommended separate war deployment approach specified here:
http://wiki.orbeon.com/forms/doc/developer-guide/xforms-with-java-applications
After having created the form and viewed in Orbeon Form Builder, I placed the resulting xml in a views/xforms directory under the root of the Grails app and called the file test.gsp. I also placed the image file for the logo of the form in the same directory. I created a war file and placed in an instance of Tomcat 7 where the orbeon.war was deployed. When I invoke the test.gsp, the form comes up sans the image file or any of the labels specified in the XForm!
Why would all labels not render?
Where do I place resources such as an image file so that it appears?
Thanks!

I recommend you don't go the route of using Form Builder to generate a form, and copying the source somewhere else. It see 3 main drawbacks:
Some elements generated by Form Builder are expected to be interpreted by the Form Builder runtime; so they won't be understood by Orbeon Forms when they are generated by your code. I am thinking of fr:view, fr:section and the like.
Form Runner services used for persistence, internationalization, PDF generation… most likely won't work.
The copy-paste process is by itself not recommendable.
The separate deployment assumes that you're using another framework and that you're going to be writing XForms in a text editor, while Form Builder is targeted at "form authors" (not necessarily developers); it uses its own runtime which requires request to hit Orbeon Forms, that is those URLs starting with /fr.

All static files, like images must be placed at web-app/*/ dir, and linked by using <g:resource> tag.
For example, for images you have to put your image ('test.png' for example) into web-app/images/ and use following code in your gsp: <img src="${resource(dir:'/images/settings', file:'test.png')}">
See docs for this tag: http://grails.org/doc/latest/ref/Tags/resource.html

Related

Unable to inject the custom JavaScript in .Net Core 2.2 in swagger

I have written a JavaScript which I would like to inject in swagger with .Net Core 2.2. I would like to highlight that wwwroot folder wasn't created by default when I created web project (empty project option) with .Net Core 2.2. I then created wwwroot folder manually and added my JavaScript file inside that. When I am launching swagger, I am getting an error that file couldn't be loaded. I tried to create a folder "swagger" inside wwwroot and place a file there but that too didn't work.
Here is my sample code:
SwaggerUIOptions uiConfig;
uiConfig.InjectJavascript("mycustomfile.js");
Also I would like to highlight what I am trying to achieve here. I got a drop-down in my header for a database provided i.e. Oracle/MSSQL etc. Now based on the selection, I want to change the value of another header i.e. connection string. I have written a JavaScript for this purpose but let me know if that can be achieved in some other and simplistic way as well with .Net Core along withSwashbuckle.
The issue got resolved after using app.UseStaticFiles(); in Configure() method.

Orbean Server side embedding - CSS issues

We are trying use Orbeon Form runner with server-side embedding.
The form renders properly on form runner, however in our java web application the form is not rendered properly i.e. CSS issues.
All the /orbeon/* resources are retrieved from orbeon application, but the CSS is not applied properly. I suspect it could be because of the extra div that are added for the embedded/portlet.
In Form Runner
Full Size Image
In Java Web Application
Full Size Image
Also, if we use the wizard view, it works in form runner, but does not work in embedded java web application. The sections are shown on the same screen.
When Orbeon Forms produces the whole page, it adds an orbeon class on the body, and then pretty much all the CSS that comes with Orbeon Forms is "prefixed" with .orbeon …. This is done to minimize the risk of Orbeon Forms' CSS conflicting with your own CSS.
I can't be sure that this is the problem, but if the CSS doesn't apply when embedding, you might need to add a class="orbeon" on the element that contains the content you're embedding.
Thanks for your guidance. I was able to resolve the problem.
When embedding forms, as you said orbeon regenerates the CSS, and also appends "o0" (#o0xforms-form) to each control's id. However, the xforms.css still refers to control with (id #xforms-form), hence styles are not applied correctly.
Overwritten the xforms.css with custom app-xforms.css which uses (#o0xforms-form) which fixes the problem.

Static content separation in JSF2.0 project

I need your help on below.
I have JSF2.0 application which runs on WAS8.5. I want to separate the static and dynamic contents as we want to use WAS server only for dynamic contents and IHS to server static contents for my application. My current architecture and design as follows:
Marked file serving flag as false in ibm-web-ext.xml file (IBM config file to say whether WAS to be served static content or Not).
We’ve used core JSF2.0 tages (h:outputStylesheet, h:outputScript and h:graphicImage) and also traditional html tags some places (link, script and img) to load static contents.
My understanding/Observation is,
1. When we load static contents using JSF2.0 components (styles using h:outputStylesheet component, java scripts using h:outputScript and images using h:graphicImage), all static contents will be served by WAS server as FacesServlet is responsible for reading the component and loading the resources accordingly. According to the JSF2.0 guidelines&standard, we should use JSF tags to load the resources like js, css and images.
2. When we load static contents using html tags, all the static contents served by webserver ie IHS
Now my question is,
My application is internet channel application where we want to serve the possible as quickly as possible. Technically, I want to use Core JSF tags wherever possible and use the WAS server to serve only dynamic contents to reduce the load.
Please advice me options to meet my requirement.
Thanks,
Nanjundan Chinnasamy
We have made the following code changes to achieve our requirement.
To server all images by IHS,
Use native JSF2.0 tag with value attribute like below.
This will generate the html source like below
We used the traditional html tags (used in JSF1.X) versions to load css and java script files like below
If we use h:outputScript and h:outputStylesheet tags available in JSF2.0, we have a name attribute which marked as mandatory. We unable to make it static reference using value attribute alone. We don’t have much documentation at MyFaces site to give references to you. Mean time, you can have a look the following:
https://myfaces.apache.org/core20/myfaces-impl/tagdoc/h_outputScript.html
https://myfaces.apache.org/core20/myfaces-impl/tagdoc/h_outputStylesheet.html
If you any other suggestion/comments, please do let me know. We will revert you with an update.
Thanks,
Nanjundan Chinnasamy

ORBEON Forms source code

I have imported orbeon war file in my Eclipse IDE and using my war file i have created new forms but i dono where the source code generated for my new forms,
what i have tried is downloaded the war, file and imported into my eclipse IDE using this war file i have created new forms.
and my link is http://orbeon.com/orbeon/fr/orbeon/builder/edit/be0b8be388fc248859fffd0cfb04a237cc8da6a6
anyone please answer me asap,
Thanks in advance.
Form Data and Definitions are stored via the persistence API. For more info look at Form Runner/Form Builder Persistence API.
When you say you have used the war file to create forms - do you mean you have used the Form Buidler interface?
Your link is to the orbeon.com server. Is that correct?

Using Form-Builder-Generated-Form with Java Application

I tried the approach of using Form-Builder-Generated-Form within Java application suggested here < Running Orbeon-Form-Builder-Generated-Form with Java Application > : downloaded Orbeon nightly build, created a sample form using Form Builder and copy & pasted it into JSP page in my app. However, when I try to access this JSP, it redirects me to: /myapp/fr/unauthorized . Can you please tell me what I maybe doing wrong? Or what is the right way of making Orbeon process Form Builder generated content in Java app?
For my deployment I followed separate deployment and configuration specified in Orbeon documentation. Thanks in advance.
You are not doing anything wrong, but Orbeon Forms doesn't support this type of form deployment.
The separate deployment mode runs the output of your JSP directly through the XForms engine.
Form Builder-generated forms OTOH expect pre-processing via the Form Runner runtime, in particular through the components.xsl XSLT transform. This is needed to support all the Form Runner features, including built-in persistence, error summary, internationalization, etc.
Currently the cleanest way to integrate such forms with your own app is to just run them side by side (Orbeon WAR + your own WAR) and navigate between each other via links and POSTs.
You could also use an iframe, although that is often a disliked solution.
You could also transform the form produced by Form Builder into plain XForms that doesn't assume Form Runner. It wouldn't be too hard to do but would be outside the scope of this StackOverflow question.

Resources