-
1. Re: create task at runtime
mailinator Jul 24, 2007 10:55 AM (in response to massimiliano_cuccia)Hi,
your taskInstance is named newti or u r calling ti.getTaskController () ...
Regards,
O.M. -
2. Re: create task at runtime
massimiliano_cuccia Jul 24, 2007 11:00 AM (in response to massimiliano_cuccia)the first portion of code is from the handler, the name for the newly created task is newti
the second portion of code is from the struts action to execute a generic task, that i'm using to execute this task also. In this fragment the name of the task instance is ti.
It isn't a java mistake ... be sure! -
3. Re: create task at runtime
syngolis Jul 24, 2007 12:20 PM (in response to massimiliano_cuccia)I think the null pointer exception is correct. AFAIK if you create a task, there is no task controller created automatically. (Think of a processdefinition; there you have to declare the controller as well)
And the get operation results in a null pointer because no controller exists. -
4. Re: create task at runtime
massimiliano_cuccia Jul 24, 2007 12:28 PM (in response to massimiliano_cuccia)"syngolis" wrote:
I think the null pointer exception is correct. AFAIK if you create a task, there is no task controller created automatically. (Think of a processdefinition; there you have to declare the controller as well)
And the get operation results in a null pointer because no controller exists.
thanks syngolis
I think that you are right: it is possible.
So I want to list all and only the variables linked to the task (not the "all task of the process"). At now I'm doing thisTaskController taskController = ti.getTask().getTaskController(); if (taskController!=null) { List variableAccesses = taskController.getVariableAccesses(); Iterator i = variableAccesses.iterator(); while (i.hasNext()) { // do something } }
but the first row gives the null pointer exception (this means that ti.getTask() is null)
so if you are right, the question is
how to list the variables of the task?
regards -
5. Re: create task at runtime
syngolis Jul 25, 2007 1:55 AM (in response to massimiliano_cuccia)"massimiliano_cuccia" wrote:
(this means that ti.getTask() is null)
No, this means getTaskController() is null, as I mentioned in the post before. Try it without the controller or create one.
In order to get variables (without variableaccess):taskInstance.getVariable("Name")
For further information, please have a look at the testcases. There are much examples. -
6. Re: create task at runtime
massimiliano_cuccia Jul 25, 2007 5:03 AM (in response to massimiliano_cuccia)"syngolis" wrote:
"massimiliano_cuccia" wrote:
(this means that ti.getTask() is null)
No, this means getTaskController() is null,
I'm sorry, but you are wrong
to prove this I added these few linesSystem.out.println( "ti: " + ti ); System.out.println( "ti.getTask(): " + ti.getTask() ); System.out.println( "ti.getTask().getTaskController(): " + ti.getTask().getTaskController() );
and obtained this outputti: TaskInstance[creato a runtime] ti.getTask(): null java.lang.NullPointerException at it.acme.action.AttivitaEsecuzione.execute(AttivitaEsecuzione.java:71)
"syngolis" wrote:
Try it without the controller
do you know a way to do this without the controller?"syngolis" wrote:
or create one.
ok, i'm trying this"syngolis" wrote:
In order to get variables (without variableaccess):taskInstance.getVariable("Name")
but I doesn't know the variable name
I'm writing an action to execute a generic task and the variable name is decided at design time!!
I'm searching for the testcases
thanks
any other can help? -
7. Re: create task at runtime
syngolis Jul 25, 2007 8:28 AM (in response to massimiliano_cuccia)sorry...I was wrong.
(You neither have a task, nor a taskcontroller. So both of them would cause the nullpointer.)
I am very interested in that issue so i will test myself a little bit. I found a testcase called: RuntimeTaskCreationTest. Maybe that helps. -
8. Re: create task at runtime
massimiliano_cuccia Jul 25, 2007 9:14 AM (in response to massimiliano_cuccia)FIXED!!!
I changed some things
I attached the handler on node leave
in the handler I created the new task and created a new variable usingtCompDoc.setVariableLocally(varname, varvalue);
then in the action to execute a task I calledti.getVariablesLocally()
to obtains the list of variables defined in the executing task
now I doesn't care about ti.getTask that is null
i doesn't care about a taskcontroller
i doesn't care about any other boring stuff
thanks to syngolis!
If someone has any questions about my code can ask me!
regards