JBoss Community

Re: Java code accessing task variables

created by LOGANATHAN KRISHNAN in jBPM - View the full discussion

Hi,

 

In order to access varaibles inside the Human Task, you have to map those variables in to the Human Task in workflow definition using Parameter Mapping attribute in the properties tab. Note that the parameter map for the Human Task should be of 'Content' only.

 

Also in the code, you have to invoke taskData.getDocumentContentId() to get the content which contains the parameter values that mapped in the definition. The sample code is as follows:

 

public static Object getContent(long contentId) {

        connect();

        Object obj = null;

        try {

            BlockingGetContentResponseHandler responseHandler = new BlockingGetContentResponseHandler();

            client.getContent(contentId, responseHandler);

            Content content = responseHandler.getContent();

            byte[] byteContent = content.getContent();

            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(

                    byteContent);

 

            ObjectInputStream inputStream = new ObjectInputStream(

                    byteArrayInputStream);

            obj = inputStream.readObject();

        } catch (Throwable t) {

            t.printStackTrace();

        }

        return obj;

    }

 

 

Hope this helps to solve your problem.

 

Regards,

Loga

Reply to this message by going to Community

Start a new discussion in jBPM at Community