<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: Task Human - Parameter Mapping
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/devilkazuya99">TC ONG</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/729764#729764">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I figured it out now. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Step 1: Create a variable in your process. (I use userComms, it's my POJO)</p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/2-729764-18391/Screen+shot+2012-04-13+at+1.27.17+PM.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/2-729764-18391/310-158/Screen+shot+2012-04-13+at+1.27.17+PM.png </span></a></p><p>Step 2: In the Human Task Parameter Mapping, map my variable to "Content". </p><p><span>(I always have this problem doing this. See </span><a class="jive-link-external-small" href="https://community.jboss.org/message/729763#729763#729763" target="_blank">https://community.jboss.org/message/729763#729763</a><span> )</span></p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/2-729764-18392/Screen+shot+2012-04-13+at+1.29.21+PM.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/2-729764-18392/450-113/Screen+shot+2012-04-13+at+1.29.21+PM.png </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Step 3: [Optional] In the On Entry Action of the Human Task, I set the value of my POJO. You can do it any way you like.</p><p>Question: is the kcontext.setVariable() necessary? </p><blockquote class="jive-quote"><p class="p1">userComms = <span class="s1"><strong>new</strong></span> UserComms();</p><p class="p1">userComms.setQuestion(<span class="s2">"Hello World~!"</span>);</p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p1">kcontext.setVariable(<span class="s2">"userComms"</span>, userComms);</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Step 4: Compile and run our process.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Step 5: Accessing your variable from the task's "Content"</p><blockquote class="jive-quote"><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;BlockingGetTaskResponseHandler taskResponseHandler = <span class="s1">new</span> BlockingGetTaskResponseHandler();</p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;taskClient.getTask(task1.getId(), taskResponseHandler);</p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;Task task = taskResponseHandler.getTask();</p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;<span class="s1">long</span> documentContentId = task.getTaskData().getDocumentContentId();</p><p class="p2">&#160; </p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;UserComms userComms = <span class="s1">new</span> UserComms();</p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;BlockingGetContentResponseHandler contentResponseHandler = <span class="s1">new</span> BlockingGetContentResponseHandler();</p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;taskClient.getContent(documentContentId, contentResponseHandler);</p><p class="p1">&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;Content content = contentResponseHandler.getContent();</p><p class="p2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="s1">if</span> (content != <span class="s1">null</span>){</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ByteArrayInputStream bais = <span class="s1">new</span> ByteArrayInputStream(content.getContent());</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ObjectInputStream ois;</p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="s1">try</span> {</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ois = <span class="s1">new</span> ObjectInputStream(bais);</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Object obj = ois.readObject();</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.<span class="s2">out</span>.println(<span class="s3">"Object = "</span> + obj.getClass());&#160; // will return an empty string if not mapped properly</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="s1">if</span>(obj <span class="s1">instanceof</span> UserComms) {</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; userComms =(UserComms) obj;</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.<span class="s2">out</span>.println(userComms.getQuestion());</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } <span class="s1">catch</span> (IOException e) {</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } <span class="s1">catch</span> (ClassNotFoundException e) {</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();</p><p class="p2" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p class="p1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p></blockquote><p class="p1" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="p1">And I got my POJO from the Content.</p><p class="p1">Happy. <span> :) </span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/729764#729764">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>