3 Replies Latest reply on Jun 30, 2008 6:24 PM by Alex Kavo

    todo example: Starting a simple task failed

    Alex Kavo Novice

      Hello!


      I've tried to rebuild the todo example .
      It is working fine so far except the done button. There is problem with the posting of the taskInstance attribute to start and stop a task.
      Here is my todox.html:


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            template="layout/template.xhtml">
      
              <head>
      <title>Todo List</title>
      </head>
      <body>
      <h1>Todo List</h1>
      <f:view>
         <h:form id="list">
            <div>
               <h:outputText value="There are no todo items." 
                             rendered="#{empty taskInstanceList}"/>
               <h:outputText value="#{task}"/>
               <h:dataTable value="#{taskInstanceList}" var="task" 
                            rendered="#{not empty taskInstanceList}">
                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="Description"/>
                      </f:facet>
                      <h:inputText value="#{task.description}"/>
                  </h:column>
                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="Task Instance ID"/>
                      </f:facet>
                      <h:inputText value="#{task.id}"/>
                  </h:column>
                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="Created"/>
                      </f:facet>
                      <h:outputText value="#{task.taskMgmtInstance.processInstance.start}">
                          <f:convertDateTime type="date"/>
                      </h:outputText>
                  </h:column>
                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="Priority"/>
                      </f:facet>
                      <h:inputText value="#{task.priority}" style="width: 30"/>
                  </h:column>
                  <h:column>
                      <f:facet name="header">
                          <h:outputText value="Due Date"/>
                      </f:facet>
                      <h:inputText value="#{task.dueDate}" style="width: 100">
                          <f:convertDateTime type="date" dateStyle="short"/>
                      </h:inputText>
                  </h:column>
                  <h:column>
                      <h:commandButton value="Done" action="#{todoList.done}" taskInstance="#{task.id}"/>
                  </h:column>
               </h:dataTable>
            </div>
            <div>
            <h:messages/>
            </div>
            <div>
               <h:commandButton value="Update Items" action="update"/>
            </div>
         </h:form>
         <h:form id="new">
            <div>
               <h:inputText value="#{todoList.description}"/>
               <h:commandButton value="Create New Item" action="#{todoList.createTodo}"/>
            </div>
         </h:form>
      </f:view>
      </body>
      
      </html>


      Especially this part causes problems:


      <h:commandButton value="Done" action="#{todoList.done}" taskInstance="#{task.id}"/>


      And this is my TodoList.java class:


      @Name("todoList")
      public class TodoList {
      
           private String description;
      
           public String getDescription() {
                return description;
           }
      
           public void setDescription(String description) {
                this.description = description;
           }
      
           @CreateProcess(definition = "todo")
           public void createTodo() {
           }
      
           @StartTask @EndTask
           public void done() {
           }
           
      }



      I get this error:


      Caused by javax.servlet.ServletException with message: "#{todoList.done}: java.lang.IllegalStateException: task/process id may not be null


      I don't understand this because I know that the taskInstance id is not null. I made some simple printouts to see the task ids.


      Please give me a hint.
      Thx.

        • 1. Re: todo example: Starting a simple task failed
          Mike Kuul Newbie

          This is strange. I built (using ant) the todo example from the seam directory and tried it: it is working. So the code must be ok.
          I copied every source code to my own project to create the same project myself than I also get this error. Really strange.

          • 2. Re: todo example: Starting a simple task failed
            Alex Kavo Novice

            I think the problem has something to do with these tags:


            This tag:


            <s:button action="#{todoList.done}" taskInstance="#{task}" value="Done"/>


            and this

            <h:commandButton value="Done" action="#{todoList.done}" taskInstance="#{task}">



            As far as I understand <s:button ...> can't be used anymore. Right?
            So, what else can I use instead?


            • 3. Re: todo example: Starting a simple task failed
              Alex Kavo Novice

              Hi all!


              I solved the problem. I just forgot to add a s library. Now my xhtml looks like this:


              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <html xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:s="http://jboss.com/products/seam/taglib"
                    template="layout/template.xhtml">
              
                      <head>
              <title>Todo List</title>
              </head>
              <body>
              <h1>Todo List</h1>
              <f:view>
                 <h:form id="list">
                    <div>
                       <h:outputText value="There are no todo items." 
                                     rendered="#{empty taskInstanceList}"/>
                       <h:outputText value="#{task}"/>
                       <h:dataTable value="#{taskInstanceList}" var="task" 
                                    rendered="#{not empty taskInstanceList}">
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Description"/>
                              </f:facet>
                              <h:inputText value="#{task.description}"/>
                          </h:column>
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Task Instance ID"/>
                              </f:facet>
                              <h:inputText value="#{task.id}"/>
                          </h:column>
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Created"/>
                              </f:facet>
                              <h:outputText value="#{task.taskMgmtInstance.processInstance.start}">
                                  <f:convertDateTime type="date"/>
                              </h:outputText>
                          </h:column>
                          
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Process ID"/>
                              </f:facet>
                              <h:outputText value="#{task.taskMgmtInstance.processInstance.id}">
                                  <f:convertDateTime type="date"/>
                              </h:outputText>
                          </h:column>
                          
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Priority"/>
                              </f:facet>
                              <h:inputText value="#{task.priority}" style="width: 30"/>
                          </h:column>
                          <h:column>
                              <f:facet name="header">
                                  <h:outputText value="Due Date"/>
                              </f:facet>
                              <h:inputText value="#{task.dueDate}" style="width: 100">
                                  <f:convertDateTime type="date" dateStyle="short"/>
                              </h:inputText>
                              
                          </h:column>
                          <h:column>
                              <s:button action="#{todoList.done}" taskInstance="#{task}" value="Done"/>
                          </h:column>
                       </h:dataTable>
                    </div>
                    <div>
                    <h:messages/>
                    </div>
                    <div>
                       <h:commandButton value="Update Items" action="update"/>
                    </div>
                 </h:form>
                 <h:form id="new">
                    <div>
                       <h:inputText value="#{todoList.description}"/>
                       <h:commandButton value="Create New Item" action="#{todoList.createTodo}"/>
                    </div>
                 </h:form>
              </f:view>
              </body>
              
              </html>


              At the beginning of the xhtml file I just added this:


              xmlns:s="http://jboss.com/products/seam/taglib"