• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retrieving Variable from Javascript and Pass it to <s:hidden> then through the Actionclass.

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using jquery struts2 grid plugin. I am using my own form to update, delete and insert object. I had created a hidden field to retrieved the value from javascript but it did not work... I also created a <s:textfield> it could not retrieve the value of the variable from javascript.. What seems to be the problem?

When I click the grid code below is activated.

var product_id = grid.jqGrid('getCell', sel_id, 'product_Id');


I want to pass the value of product_id to the hidden tag in struts2 by this.


document.getElementById('product_Id').value = product_id;



So it should pass the product_id value to product_Key field through this tag.

<s:hidden value="" name="product_Key" id="product_Id"/>



Then when i click the edit button on the grid, it should be passed as a paremeter through this lines.

<

s:url id="editurl" action="ProductUpdate">
<s:param name="product_Key"><s:property value="product_Key"/></s:param>
</s:url>


This is the edit click button.


Edit : {
title :'Edit record on the selected record on the row',
caption :'Edit Record',
icon:'ui-icon-pencil',
onclick: function(){ alert('Edit is clicked'),document.getElementById('product_Id').value = product_id,window.location = '%{editurl}' }
}







My Action Class

 
Ranch Hand
Posts: 47
MyEclipse IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem is struts tags are loaded first, quite astonished to see javascript code use jquery, much more easier
try $("#idofgrid").jqGrid('getGridParam', ....); to get grid params just a hint

Hope this helps
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I placed the hidden field at the bottom... nothing happend... hmm i need to check jquery raw.... im only using plugin which is easy.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic