Struts2: Hidden field and anchor tag <s:a> values In Action Class -


I am working on a struts2 application in my jsp page I have 2-3 anchor tags and 2-3 hidden Fields such as

  & lt; S: a href = "#" & gt; File 1 & lt; / S: a & gt; & Lt; S: a href = "#" & gt; File 2 & lt; / S: a & gt; & Lt; S: a href = "#" & gt; File 3 & lt; / S: a & gt;  

and

  & lt; S: hidden name = "hidden 1" /> & Lt; S: hidden name = "hidden 2" /> & Lt; S: hidden name = "hidden" />  

Now please tell me, how can I get the value of all the hidden areas and anchor tags in my action class which was clicked?

I did the following

  & lt; S: a href = "#" verb = "some action" & gt; File 1 & lt; / S: a & gt;  

It is working but the value of the hidden files has not been transferred. Also

  & lt; S: a href = "#" name = "file1" onclick = "submit" & gt; File 1 & lt; / S: a & gt;  

But no use.

Looking for your answer. Like Boris said, you have to keep the hidden field inside a form, and that form You have to submit, or you can add them as a URL parameter of your link. The best method is possibly using a form with POST, so hidden fields are not on your browser's location bar.

Here is an example

   "myoform" name = "myform" action = "some action" method = "post" & gt; & Lt; S: hidden name = "hidden 1" value = "first value" /> & Lt; S: hidden name = "hidden 2" value = "second value" /> & Lt; S: hidden name = "hidden" value = "third value" /> & Lt; A href = "#" name = "file1" onclick = "document.forms [myform ']. Submit ();" & Gt; Submit with link & lt; / A & gt; & Lt; S: submit the value = "% {" submit with the button}} "/> & lt; / S: Forms & gt;  

Since this is actually nothing to do with struts2, here is an example with pure HTML:

  & lt; Form id = "myform" name = "myform" action = "some action. Action" method = "post" & gt; & Lt; Input type = "hidden" name = "hidden" value = "first value" /> & Lt; Input type = "hidden" name = "hidden" value = "second value" /> & Lt; Input type = "hidden" name = "hidden" value = "third value" /> & Lt; A href = "#" name = "file1" onclick = "document.forms [myform ']. Submit ();" & Gt; Submit with a link & lt; / A & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "submit with a button" /> & Lt; / Form & gt;  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -