05-08-2012 02:23 PM
I have the following custom EL expression in a user Action:
${layoutValue.currentLifeCycleState != 'SupRequest1' && layoutValue.currentLifeCycleState != 'SupRequest2' && layoutValue.currentLifeCycleState != 'Pause'}
I have two documents one in the SupRequest1 state and one in the Start state.
The button associated with this user action is enabled in both documents. Expected result is: Button is missing from document in SupRequest1 state and present in document in Start state.
Am I missing a logic error?
Will the above expression be completely parsed by Nuxeo?
BTW a compound boolean expression in another user action with only two clauses seems to work correctly!
Also if I use parentheses, to enclose each clause, in the expression the Nuxeo parser get very upset and cannot find the first && (AND) operator.
See Entry entitled: User Action: Current document has life cycle ......NOT!? as a reference.
05-10-2012 10:19 AM
In a user action, you do not have access to the layout context as it's unrelated. So layoutValue variable will always resolve to null here.
You can however use EL expressions using "document" or "currentDocument" (this one since 5.5), other variables available in the context are "principal" or "currentUser" (this one also since 5.5).
You can also call a custom method from a Seam component, but the Seam component has to be the first item of the expression to be resolved correctly, so something like #{clipboardActions.canPasteFromClipboard}
will work, but not something like #{clipboardActions.canPasteFromClipboard and clipboardActions.canDoOtherStuff}
.
We do know that this can be confusing for users, hopefully we'll improve that in the future...
05-10-2012 10:19 AM
In a user action, you do not have access to the layout context as it's unrelated. So layoutValue variable will always resolve to null here.
You can however use EL expressions using "document" or "currentDocument" (this one since 5.5), other variables available in the context are "principal" or "currentUser" (this one also since 5.5).
You can also call a custom method from a Seam component, but the Seam component has to be the first item of the expression to be resolved correctly, so something like #{clipboardActions.canPasteFromClipboard}
will work, but not something like #{clipboardActions.canPasteFromClipboard and clipboardActions.canDoOtherStuff}
.
We do know that this can be confusing for users, hopefully we'll improve that in the future...
05-10-2012 11:52 AM
For my solution I have written a custom boolean Seam method which contains all the logic needed. The method returns a boolean so I can use a single EL expression eg. #{mymethod}, this seems to work.
11-26-2012 04:15 PM
I followed your steps and created a seam controller bean with a method which returns a boolean. Now how do invoke this method from a custom EL.? Where do i register this seam bean?
11-26-2012 04:44 PM
Here is an example:
In the Nuxeo IDE I created a Seam Controller Bean named enables using class EnablesBean. The bean has many methods each returning a boolean after it tests what ever I need to test. Most of the code below is automatically generated by the IDE. A sample method is show below, make as many methods as you need for various enables. I changed the Scope to Event which helped with some issues I had, change Scope as required to make it work appropriately for your code..
Start Code ***************************
package org.nuxeo.zaxis.bes;
import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.GregorianCalendar; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Factory; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.NuxeoPrincipal; import org.nuxeo.ecm.core.api.model.PropertyException; import org.nuxeo.ecm.platform.ui.web.invalidations.AutomaticDocumentBasedInvalidation; import org.nuxeo.ecm.platform.ui.web.invalidations.DocumentContextBoundActionBean; import org.nuxeo.ecm.webapp.documentsLists.DocumentsListsManager;
/**
*/
//The Bean is registered here! //This was automatically generated by the Nuxeo IDE
@Name("enables") @Scope(ScopeType.EVENT) @AutomaticDocumentBasedInvalidation public class EnablesBean extends DocumentContextBoundActionBean implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(besEnablesBean.class);
public boolean sampleTest(){
boolean result = false;
// DO your check here and set result variable as required. You can // make the check as simple or as complicated as you'd like.
return result;
}
}
End Code*********************************
Add a EL expression in the filter in the Action, Content View, etc, like below (I use Studio but I'm sure it will work in .XML):
${enables.sampleTest()}
That's about it.
Karl
11-26-2012 05:06 PM
Thanks a lot its working
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.