Changeset 10784

Show
Ignore:
Timestamp:
01/29/07 01:51:22 (2 years ago)
Author:
fguillaume
Message:

Stateless action listener, so that some injections work correctly. Example document changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.project.sample/trunk/NXSample/.classpath

    r10655 r10784  
    1010        <classpathentry kind="lib" path="/Nuxeo/lib/jboss-seam.jar" sourcepath="/install/jboss-seam-1.1.0.GA/src"/> 
    1111        <classpathentry combineaccessrules="false" kind="src" path="/Nuxeo"/> 
     12        <classpathentry combineaccessrules="false" kind="src" path="/NXCoreFacade"/> 
    1213        <classpathentry kind="output" path="bin"/> 
    1314</classpath> 
  • org.nuxeo.project.sample/trunk/NXSample/build.xml

    r10655 r10784  
    2525    </fileset> 
    2626    <fileset dir="${deploy.dir}/${nuxeo.ear}"> 
     27      <include name="NXSchema.jar"/> 
    2728      <include name="NXCoreAPI.jar"/> 
    2829      <include name="NXCore.jar"/> 
    29       <include name="NXSchema.jar"/> 
     30      <include name="NXCoreFacade.jar"/> 
    3031      <include name="nuxeo.jar"/> 
    3132    </fileset> 
    3233    <!-- 
     34    <fileset dir="../NXSchema/dist"> 
     35      <include name="NXSchema.jar"/> 
     36    </fileset> 
    3337    <fileset dir="../NXCoreAPI/dist"> 
    3438      <include name="NXCoreAPI.jar"/> 
     
    3741      <include name="NXCore.jar"/> 
    3842    </fileset> 
    39     <fileset dir="../NXSchema/dist"> 
    40       <include name="NXSchema.jar"/> 
     43    <fileset dir="../NXCoreFacade/dist"> 
     44      <include name="NXCoreFacade.jar"/> 
    4145    </fileset> 
    4246    <fileset dir="../Nuxeo/dist"> 
  • org.nuxeo.project.sample/trunk/NXSample/pom.xml

    r10419 r10784  
    2323    <dependency> 
    2424      <groupId>org.nuxeo.ecm</groupId> 
    25       <artifactId>NXJCRConnector</artifactId> 
    26       <version>0.0-SNAPSHOT</version> 
    27     </dependency> 
    28     <dependency> 
    29       <groupId>org.nuxeo.ecm</groupId> 
    30       <artifactId>NXFileManager</artifactId> 
     25      <artifactId>NXCoreFacade</artifactId> 
    3126      <version>0.0-SNAPSHOT</version> 
    3227    </dependency> 
  • org.nuxeo.project.sample/trunk/NXSample/src/org/nuxeo/project/sample/SampleAction.java

    r10653 r10784  
    55import javax.ejb.Local; 
    66 
     7import org.nuxeo.ecm.core.api.ClientException; 
     8 
    79@Local 
    810public interface SampleAction extends Serializable { 
    911 
    10     public String doSomething()
     12    public String doSomething() throws ClientException
    1113 
    1214    public String getSampleName(); 
    1315 
    14     public void setSampleName(String sampleName); 
    15  
    1616    public void destroy(); 
    1717} 
  • org.nuxeo.project.sample/trunk/NXSample/src/org/nuxeo/project/sample/SampleActionBean.java

    r10655 r10784  
    44 
    55import javax.ejb.Remove; 
    6 import javax.ejb.Stateful; 
    76 
    87import org.apache.commons.logging.Log; 
     
    1413import org.jboss.seam.annotations.Scope; 
    1514import org.jboss.seam.contexts.Contexts; 
     15import org.nuxeo.ecm.core.api.ClientException; 
    1616import org.nuxeo.ecm.core.api.DocumentModel; 
    17 import org.nuxeo.ecm.ui.web.context.NavigationContext
     17import org.nuxeo.ecm.core.api.ejb.DocumentManager
    1818 
    1919// XXX: when contributed outside of Nuxeo, seam components do not get injected 
    2020// in the bean if it's declared stateful... 
    21 @Stateful 
     21// @Stateful 
    2222@Scope(SESSION) 
    2323@Name("sampleActions") 
     
    3232    //protected NavigationContext navigationContext; 
    3333 
    34     protected String sampleName = "click"; 
     34    @In(create = true) 
     35    protected DocumentManager documentManager; 
    3536 
    3637    public String getSampleName() { 
    37         return sampleName; 
     38        DocumentModel doc = (DocumentModel) Contexts.getSessionContext().get("currentItem"); 
     39        if (doc == null) { 
     40            log.info("doc null"); 
     41            return "null doc!"; 
     42        } 
     43        return (String) doc.getProperty("dublincore", "title"); 
    3844    } 
    3945 
    40     public void setSampleName(String sampleName) { 
    41         this.sampleName = sampleName; 
    42     } 
     46    public String doSomething() throws ClientException { 
     47        log.info("Doing something"); 
    4348 
    44     public String doSomething() { 
    45         log.info("Doing something"); 
     49        //XXX injected incorrectly 
    4650        //DocumentModel doc = navigationContext.getCurrentDocument(); 
    4751        DocumentModel doc = (DocumentModel) Contexts.getSessionContext().get("currentItem"); 
    4852        if (doc == null) { 
    4953            log.info("doc null"); 
    50             sampleName = "null doc!"; 
    51         } else { 
    52             sampleName = sampleName + " " + doc.getType(); 
     54            return null; 
    5355        } 
     56        if (documentManager == null) { 
     57            log.info("dm null"); 
     58            return null; 
     59        } 
     60 
     61        String title = (String) doc.getProperty("dublincore", "title"); 
     62        title += " do"; 
     63        doc.setProperty("dublincore", "title", title); 
     64        documentManager.saveDocument(doc); 
     65        documentManager.save(); 
    5466        return null; 
    5567    } 
  • org.nuxeo.project.sample/trunk/NXSample/web/incl/tabs/sample_view.xhtml

    r10653 r10784  
    3333<h:form> 
    3434  <h:panelGrid> 
    35     <h:inputText value="#{sampleActions.sampleName}"/> 
     35    <h:outputText value="#{sampleActions.sampleName}"/> 
    3636    <h:commandButton type="submit" 
    3737      value="Do Something" styleClass="button"