Creating a Studio layout and calling it correctly in the IDE - adding a tab to the document

Hello,

Thanks to the help provided at http://answers.nuxeo.com/questions/2205/fill-up-a-form-when-the-document-state-is-to-be-changed-within-a-workflow by @bjalon, I was able to move ahead and create a layout in Nuxeo Studio.

This layout is to display as an additional tab “Send to Client” when the document is in certain lifecycle state “approved”.

The layout is a form containing multiple choice questions with options and some text inputs.

From the “approved” state the document lifecycle has been modified so that it can either return back to “project” by additional editing OR move ahead to be submitted to client and attain the lifecycle state “client”.

To move from the “approved” to the “client” state, the only route is to navigate to the tab “Send to Client”, fill the form and submit. In case the form is submitted without errors, the document state becomes “Client” and the tab goes away. This change of state including the filling up of the form in the layout is captured in history AND the date entered in the form also needs to be stored.

I was able to create a sample layout form, identifier TAB_CLIENT, using Studio but faced these issues

  1. No option for Radio buttons in the widgets

  2. List item3.

  3. No option for submit button in the widgets

  4. Having to create Vocabularies for “selectOneDirectory” widget used since the radio buttons were not available.

I downloaded the files, included the files relevant to the newly created layout within an empty project in Nuxeo Eclipse IDE and defined the contributions in extensions.xml within “OSGI-INF”.

I created a new xhtml file called mytabs.xhtml as suggested by bjalon in the link above. Now I am faced with the dilemma of how to call my layout in this file?

Considering that these files were relevant to the layout that I created

  1. TAB_CLIENT.layout.xml in “.metadata” folder

  2. TSegment.voc.xml, Relevance.voc.xml, Comprehensiv.voc.xml -> in “.metadata” -> vocabulary files used

  3. TSegment.csv, Relevance.csv, Comprehensiv.csv in “\data\vocabularies”

  4. Multiple widget files in “\web\nuxeo.war\widgets” that were used in the layout

In the “\web\nuxeo.war\layouts” folder, there are 3 few layout files

studio_layout_summary_template.xhtml

studio_layout_header_template.xhtml

xyz_layout_template.xhtml - a layout file with the name of my project in studio.

In addition there were other files and schema that are packaged by default when downloading from Studio but not relevant to this requirement.

The package download from studio, in its extension.xml has references to the TAB_CLIENT@create, TAB_CLIENT@edit and TAB_CLIENT@view layouts under

It also references as below within each layout

  <templates>
    <template mode="any">/layouts/xyz_layout_template.xhtml</template>
  </templates>

With the above I have been able to add the necessary tab to the document view. I have even been able to add a user action “Send to Client”, visible in “approved” state, as a shortcut to click and automatically switch to the tab.

However when I click the tab, it gives and UNEXPECTED ERROR “javax.servlet.ServletException” with NULL.

In this scenario, my questions are

  1. How to correctly call the layout to the mytabs.xhtml as suggested in the URL above? Or do I need to call it into mytabs.xhtml at all?
  2. How to create a better layout using Studio? My form requires multiple/ Single choice questions and also needs to be arranged with tables etc.
  3. Is this the correct way to store data of the completed form as well as the history?

Apologies for the long description to put the scenario in perspective. My need is quite urgent now so any immediate help will be very welcome and appreciated.

@bjalon, I have created a new question as suggested. Any help would be wonderful as always :-)

Many thanks

0 votes

1 answers

2924 views

ANSWER

Update: I modified the content of my mytabs.xhtml file as such

<div xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jstl/core" xmlns:nxh="http://nuxeo.org/nxweb/html" xmlns:nxu="http://nuxeo.org/nxweb/util" xmlns:nxl="http://nuxeo.org/nxforms/layout">

<h:form enctype="multipart/form-data" id="document_edit"> <script>

jQuery(document).ready(function() {
  jQuery(&apos;#document_edit&apos;).focusFirst();
});

</script>

<nxl:documentLayout mode="create" value="TAB_CLIENT" />

</h:form> </div>

basing in the document.edit.xhtml

I now get the error

Cannot convert TAB_CLIENT of type class java.lang.String to interface org.nuxeo.ecm.core.api.DocumentModel

04/19/2012



Hi, The nxl:documentLayout waits for a document model as value, see documentation at http://community.nuxeo.com/api/nuxeo/5.4/tlddoc/nxl/documentLayout.html

0 votes



Anahide Tchertchian, your comment did point me to the correct direction. I modified my code as below

<nxl:layout name="TAB_CLIENT@edit" mode="edit" value="#{TAB_CLIENT}" />

The tab now loads correctly and works almost exactly as I wanted.

thank you very much.

05/03/2012