Switching image using dwr

View: New views
3 Messages — Rating Filter:   Alert me  

Switching image using dwr

by santoshmanya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 Hi All,

I had been using DWR since 2 years. I am using DWR with Spring, Hibernate and JSTL tags.

when I change the worker to inactive/active i want to change the image as inactive/active.

I am unable to change the image as a result of  dwr output. I tried setValues, but it can set values with ids, but not for img src.

below is the code snippet.
can someone help.
               
<c:choose>
        <c:when est="${cWorkers.active eq 'Y'}">
  <!--   active image -->
</c:when>
<c:when test="${cWorkers.active eq 'N'}">
<!--   inactive image -->
</c:when>
<c:otherwise>
                                                                                               
</c:otherwise>
</c:choose>


 <script type="text/javascript">
 function activateWorkerCallback(data)
    {
     
      DWRUtil.setValue("activeWorkerDiv" , data);
    }

    function inActivateWorker(param)
    {
        gomsAjax.inActivateWorker(param, inActivateWorkerCallback);
      return false;

    }



    function inActivateWorkerCallback(data)
    {
      DWRUtil.setValue("inActiveWorkerDiv" , data);
    }

  </script>

Re: Switching image using dwr

by sidd rc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you can
 use div tags and populate the divs with conditional html  (based on if else in a variable)
andf then fill the div with the required image wen u activate or deactivate a user



On Thu, Nov 5, 2009 at 2:49 AM, santoshmanya <santoshmanya@...> wrote:

 Hi All,

I had been using DWR since 2 years. I am using DWR with Spring, Hibernate
and JSTL tags.

when I change the worker to inactive/active i want to change the image as
inactive/active.

I am unable to change the image as a result of  dwr output. I tried
setValues, but it can set values with ids, but not for img src.

below is the code snippet.
can someone can help.

<c:choose>
       <c:when est="${cWorkers.active eq 'Y'}">
   active.gif
</c:when>
<c:when test="${cWorkers.active eq 'N'}">
inactive.gif
</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>


 <script type="text/javascript">
 function activateWorkerCallback(data)
   {

     DWRUtil.setValue("activeWorkerDiv" , data);
   }

   function inActivateWorker(param)
   {
       gomsAjax.inActivateWorker(param, inActivateWorkerCallback);
     return false;

   }



   function inActivateWorkerCallback(data)
   {
     DWRUtil.setValue("inActiveWorkerDiv" , data);
   }

 </script>
--
View this message in context: http://old.nabble.com/Switching-image-using-dwr-tp26204811p26204811.html
Sent from the DWR - Issues mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...



Re: Switching image using dwr

by santoshmanya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,

I just fixed the issue, instead of using img src tag, I used input type=image.
an it worked.

<c:choose>
<c:when test="${cWorkers.active eq true}">
<input type="image" id="user_active_${cWorkers.id}" src="active.gif" alt="Active"  onclick="return toggleWorkerActive(this,${cWorkers.id});" />
</c:when>
<c:when test="${cWorkers.active eq false}"> <input type="image" id="user_active_${cWorkers.id}" src="inactive.gif" alt="Inactive" onclick="return toggleWorkerActive(this,${cWorkers.id});" />
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>


function toggleWorkerActive(element, workerId) {
   // alert(workerId);
  gomsAjax.toggleWorkerActive('<%=UserUtils.getUserId(request)%>', workerId, toggleWorkerActiveCB);
  return false;
}

function toggleWorkerActiveCB(data) {
        //alert(data);
  var element = document.getElementById('user_active_' + data);
  if(element.alt == "Activate") {
    element.src = "active.gif";
    element.alt = "Inactivate";
  }
  else {
    element.src = "inactive.gif";
    element.alt = "Activate";
  }
}