02-13-2015 08:34 AM
We are trying to add a new field ("quantity") to relations.
We have created a new schema ("relation-extended"), and we have override Relation doctype adding this schema (in relation-extended-contrib.xml):
<component name="org.nuxeo.sample.relationextended">
<require>org.nuxeo.ecm.core.CoreExtensions</require>
<extension point="schema" target="org.nuxeo.ecm.core.schema.TypeService">
<schema name="relation-extended" prefix="relext" src="schema/relationextended.xsd"/>
</extension>
<extension point="doctype" target="org.nuxeo.ecm.core.schema.TypeService">
<doctype name="Relation"> <!-- no extends -->
<schema name="relation"/>
<schema name="dublincore"/>
<schema name="relation-extended"/>
</doctype>
</extension>
</component>
This is the content of the new schema:
<xs:element name="quantity" type="xs:integer" default="1"/>
We have seen that it has created a new table in the database, with an ID and the field QUANTITY.
Afterwards, we followed http://doc.nuxeo.com/display/NXDOC/How+to+Override+a+Seam+Component how to:
Created RelationExtendedActionsBean.java
package org.nuxeo.sample;
//Imports
@Name("relationActions")
@Scope(CONVERSATION)
@Install(precedence = 100)
public class RelationExtendedActionsBean extends RelationActionsBean {
private static final long serialVersionUID = 1L;
@Override
public String addStatement() throws ClientException {
return null;
}
}
Added an empty seam.properties
under the folder src/main/resources
.
Added required statements in deployment-fragment:
<fragment version="1">
<require>org.nuxeo.ecm.webapp.ui</require>
<require>org.nuxeo.ecm.relations.web</require>
<install>
<unzip from="${bundle.fileName}" to="/" prefix="web">
<include>web/nuxeo.war/**</include>
</unzip>
</install>
</fragment>
INFO logs are active in log4j.xml for Seam but we don't see our Seam component in the logs:
<category name="org.jboss.seam">
<priority value="INFO" />
</category>
/***/
<category name="org.jboss.seam.contexts.Contexts">
<priority value="INFO" />
</category>
<category name="org.jboss.seam.contexts.Lifecycle">
<priority value="INFO" />
</category>
We don't see our component in the logs if we try to override an existing one, we just see it when we create a new Seam component using Nuxeo IDE:
2015-02-19 18:09:43,491 INFO [http-bio-0.0.0.0-8080-exec-4] [org.jboss.seam.Component] Component: newRelation, scope: CONVERSATION, type: JAVA_BEAN, class: org.nuxeo.sample.NewRelationBean
We notice that it's not overriding, because it keeps creating the relation, and our addStatement does nothing. Also, the debugger doesn't stop in any breakpoint we put in our class.
The bundle structure is:
src/main/
java/org/nuxeo/sample/
RelationExtendedActionsBean.java
resources/
META-INF/
MANIFEST.MF
OSGI-INF/
extensions/
relation-extended-contrib.xml
deployment-fragment.xml
schema/
relationextended.xsd
web/nuxeo.war/
create_relation.xhtml
seam.properties
We are new in Nuxeo... What do you mean by registering our Seam bean?
Do we miss a contribution to any extension point to register our Seam component?
We just override create_relation.xhtml
, do we need to override document_relations.xhtml
?
Thank you in advance,
02-13-2015 08:18 PM
You should add new fields to your version of create_relation.xhtml. After that you should add to your deployment-fragment.xml file a require statement:
<require>org.nuxeo.ecm.relations.web</require>
Then you should replace RelationActionsBean.java by your version. You can do this by adding a proper "precedence".
@Name("relationActions")
@Scope(CONVERSATION)
@AutomaticDocumentBasedInvalidation
@Install(precedence = 100)
public class RelationActionsBean extends DocumentContextBoundActionBean
In RelationActionsBean.java it is necessary to change the addStatement method.
If you need a validation for your new fields then the RelationCreationBean.java should be also repleaced.
Adam
02-13-2015 08:18 PM
You should add new fields to your version of create_relation.xhtml. After that you should add to your deployment-fragment.xml file a require statement:
<require>org.nuxeo.ecm.relations.web</require>
Then you should replace RelationActionsBean.java by your version. You can do this by adding a proper "precedence".
@Name("relationActions")
@Scope(CONVERSATION)
@AutomaticDocumentBasedInvalidation
@Install(precedence = 100)
public class RelationActionsBean extends DocumentContextBoundActionBean
In RelationActionsBean.java it is necessary to change the addStatement method.
If you need a validation for your new fields then the RelationCreationBean.java should be also repleaced.
Adam
02-16-2015 06:11 AM
Thank you very much, Adam!! You have been very helpful 🙂
02-19-2015 10:10 AM
Hello again,
We have followed the steps you told us. But we still have some problems. We are not able to override RelationActionsBean.java
We have created the class RelationExtendedActionsBean.java following this how-to: http://doc.nuxeo.com/display/NXDOC/How+to+Override+a+Seam+Component
package com.my.package.relations;
//Imports
@Name("relationActions")
@Scope(CONVERSATION)
@Install(precedence = 100)
public class RelationExtendedActionsBean extends RelationActionsBean {
private static final long serialVersionUID = 1L;
@Override
public String addStatement() throws ClientException {
return null;
}
}
We notice that it's not overriding, because it keeps creating the relation, and our addStatement does nothing. Also, the debugger doesn't stop in any breakpoint we put in our class. And we don't see any line in the logs saying that our Seam component has loaded.
We have tried with different precedences: Install.MOCK, 100, etc.
Are we missing something?
02-19-2015 12:15 PM
This is not an answer. Please just edit your original question with what you tried, and add a comment to the given answer to say what you changed.
02-19-2015 05:29 PM
Could you show us a structure of your bundle ?
02-20-2015 05:22 AM
Sorry Florent, we have reformulated the question with all the steps we have followed.
02-24-2015 04:08 PM
I tried your example and the following one works.
The structure tree:
src/main/
java/org/nuxeo/sample/
RelationExtendedActionsBean.java
resources/
META-INF/
MANIFEST.MF
OSGI-INF/
deployment-fragment.xml
seam.properties
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-Vendor: sample
Bundle-Version: 5.8
Bundle-ManifestVersion: 2
Bundle-Name: New TEST
Bundle-SymbolicName: org.nuxeo.sample.relations.test;singleton:=true
Bundle-Category: web,stateful
deployment-fragment.xml:
<?xml version="1.0"?>
<fragment version="1">
<require>org.nuxeo.ecm.webapp.ui</require>
<require>org.nuxeo.ecm.relations.web</require>
</fragment>
RelationExtendedActionsBean.java:
package org.nuxeo.sample;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuxeo.ecm.platform.relations.web.listener.ejb.RelationActionsBean;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Install;
import static org.jboss.seam.ScopeType.CONVERSATION;
import org.nuxeo.ecm.core.api.ClientException;
@Name("relationActions")
@Scope(CONVERSATION)
@Install(precedence = 100)
public class RelationExtendedActionsBean extends RelationActionsBean {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(RelationExtendedActionsBean.class);
@Override
public String addStatement() throws ClientException {
log.debug("test add statement");
return null;
}
}
You can try it.
02-25-2015 04:57 AM
We have tried exactly the same, but it didn't work. It creates relations as always, and in the logs (server.log) the only line related to RelationActions is this
02-25-2015 05:33 AM
I have used Eclipse Luna without Nuxeo IDE and Nuxeo 5.8 HF 21.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.