You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kiwi209 <ki...@yahoo.fr> on 2011/03/03 19:37:55 UTC

Struts2 list all the parameters

Hello everybody,

Does anyone know how to get on a JSP page the list of all the parameters
available on this page ?
Thanks in advance.
-- 
View this message in context: http://old.nabble.com/Struts2-list-all-the-parameters-tp31061470p31061470.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 list all the parameters

Posted by Burton Rhodes <bu...@gmail.com>.
Would <s:debug/> do the trick for you?

On Thursday, March 3, 2011, Kiwi209 <ki...@yahoo.fr> wrote:
>
>
> Thanks for your response, the problem is that I don't know all the
> parameters set in the Action... So I would like to retrieve the list of all
> the request parameters as name / value list.
>
> (sorry for my english but it's not my natural tongue)
> --
> View this message in context: http://old.nabble.com/Struts2-list-all-the-parameters-tp31061470p31062904.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: jquery + struts2 + form validation

Posted by Chris Pratt <th...@gmail.com>.
I don't know for sure, but I think you would have to use a <s:form> tag, not
a <form> tag if you want all the automatic goodness to work.
  (*Chris*)

On Fri, Mar 4, 2011 at 8:18 AM, Emi Lu <em...@encs.concordia.ca> wrote:

> Hi Dave,
>
>
>  check_action()
>>> {
>>>      PrintWriter out          = res.getWriter();
>>>      res.setContentType("text/html");
>>>      if(error)
>>>      {
>>>         out.println("<li>Error info</li>");
>>>
>>
>> Ew.
>>
>
> What Ew means?
>
>
>  The part gives me headache is that how to submit hundreds of tags in the
>>> form in JSP?
>>>
>>
>> A form with hundreds of fields is a horrible mess anyway.
>>
>
> It depends on the usage. We have search table default only several fields
> shown. Users are allow to grab and display all hidden fields and search
> based on those criteria.
>
>
>
>
>  Is there a way, form values can be submit automatically?
>>>
>>
>> ... By submitting the form? You're going to have to be more specific
>> in your requirements--I don't know what you mean by "can the form
>> values be submit[ted] automatically"--that's what a form submission
>> does, submits all the input elements in a form.
>>
>
> An example:
> ==============================
> <s:submit action="saveRecord" onclick="return checkRecord()">
>
> Before real saving the the record into DB, check is done first.
>
> The checking is against DB operation.
>
> The jquery method checkRecord() has to say for example:
>
> <script type="text/javascript">
> function  checkRecord()
> {
> //======================= from here ===============================
>   var checkbox_value = "";
>   for(var i=0; i < document.form.checkbox_value.length; i++)
>   {
>        if(document.form.checkbox_value[i].checked)
>        {
>           checkbox_value +=
> "checkbox_value="+document.form.checkbox_value[i].value + "&";
>        }
>   }
>   if(checkbox_value != "")
>   {
>    checkbox_value = "?" + checkbox_value;
>    checkbox_value = checkbox_value.substring(0, checkbox_value.length -1);
> }
>
> //======================= to here ===============================
> var return_yn = false;
> $.ajax({
>   async: false,
>   url : "check_oprAction.action" + checkbox_value,
>   success: function(data)
>   {
>           if(data==1)
>                {
>                   return_yn = true;
>                }
>           else
>           {
>         $("#action_error_div").html(data);
>         $("#action_error_div").removeClass().addClass("errormsg");
>         return_yn = false;
>           }
>   }
> });
>   setTimeout("timeExam()", 2000);
>   alert("return_yn = " + return_yn);
>   return return_yn;
> }
> </script>
>
>
>
>
> Is there a way to escape "from here ~ to here". If the form can be submit
> when calling ajax.url, I will not need to say:
>
> check_oprAction.action?tag1=...&tag2=...&tag3=... ...tag300=.
>
>
> See the problem I had is I do not want to do "?tag1=...&tag2=...&tag3=...
> ...tag300=. " through javascript, but only submit "check_oprAction"
>
> This is just an example.
>
> Thank you,
> --
> Lu Ying
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: jquery + struts2 + form validation

Posted by adam pinder <ap...@hotmail.co.uk>.

all hidden fields will also be sent to the server using this method, but you could put those fields into a different form that isn't submitted and reference them with the form name within jquery if need be or accept them being sent - it probably will be ok performance wise as long as there isn't very high volumes.


> Date: Fri, 4 Mar 2011 13:59:38 -0500
> From: emilu@encs.concordia.ca
> To: user@struts.apache.org
> CC: apinder@hotmail.co.uk
> Subject: Re: jquery + struts2 + form validation
> 
> Hi Adam,
> 
> You provided the info exactly what I need!
> 
> Thank you very much!
> 
> For users had same question:
> http://api.jquery.com/serialize/
> 
> Only one concern:  "var str = $("form").serialize();" in the online doc 
> will not cause any performance issue if lots of (hidden)tags in the 
> form, right?
> 
> --
> Lu Ying
> 
> 
> On 03/04/2011 12:38 PM, adam pinder wrote:
> >
> >
> >
> > jquery has built in ability to submit form elements in an ajax request
> > for example
> > 	$.post("AddUser_execute.action", $("#AddUserForm").serialize(),	   function(data){	   		cursor_clear();	     $('#P4_AddUser').html(data);	   }, "html");
> >
> > this statement will post to AddUser action and all form elements in the AddUserForm will be sent - the serialize method does the name/value pairing for you
> > adam
> >
> >> Date: Fri, 4 Mar 2011 11:18:17 -0500
> >> From: emilu@encs.concordia.ca
> >> To: davelnewton@gmail.com
> >> CC: user@struts.apache.org
> >> Subject: Re: jquery + struts2 + form validation
> >>
> >> Hi Dave,
> >>
> >>>> check_action()
> >>>> {
> >>>>        PrintWriter out          = res.getWriter();
> >>>>        res.setContentType("text/html");
> >>>>        if(error)
> >>>>        {
> >>>>           out.println("<li>Error info</li>");
> >>>
> >>> Ew.
> >>
> >> What Ew means?
> >>
> >>>> The part gives me headache is that how to submit hundreds of tags in the
> >>>> form in JSP?
> >>>
> >>> A form with hundreds of fields is a horrible mess anyway.
> >>
> >> It depends on the usage. We have search table default only several
> >> fields shown. Users are allow to grab and display all hidden fields and
> >> search based on those criteria.
> >>
> >>
> >>
> >>>> Is there a way, form values can be submit automatically?
> >>>
> >>> ... By submitting the form? You're going to have to be more specific
> >>> in your requirements--I don't know what you mean by "can the form
> >>> values be submit[ted] automatically"--that's what a form submission
> >>> does, submits all the input elements in a form.
> >>
> >> An example:
> >> ==============================
> >> <s:submit action="saveRecord" onclick="return checkRecord()">
> >>
> >> Before real saving the the record into DB, check is done first.
> >>
> >> The checking is against DB operation.
> >>
> >> The jquery method checkRecord() has to say for example:
> >>
> >> <script type="text/javascript">
> >> function  checkRecord()
> >> {
> >> //======================= from here ===============================
> >>      var checkbox_value = "";
> >>      for(var i=0; i<  document.form.checkbox_value.length; i++)
> >>      {
> >>           if(document.form.checkbox_value[i].checked)
> >> 	{
> >> 	   checkbox_value +=
> >> "checkbox_value="+document.form.checkbox_value[i].value +"&";
> >> 	}
> >>      }
> >>      if(checkbox_value != "")
> >>      {
> >>       checkbox_value = "?" + checkbox_value;
> >>       checkbox_value = checkbox_value.substring(0, checkbox_value.length
> >> -1);
> >> }
> >> 	
> >> //======================= to here ===============================
> >> var return_yn = false;
> >> $.ajax({	
> >>      async: false,
> >>      url : "check_oprAction.action" + checkbox_value,
> >>      success: function(data)
> >>      {
> >> 	   if(data==1)
> >> 		{
> >> 		   return_yn = true;
> >> 		}
> >> 	   else
> >> 	   {
> >>            $("#action_error_div").html(data);
> >>            $("#action_error_div").removeClass().addClass("errormsg");
> >>            return_yn = false;
> >> 	   }
> >>      }
> >> });
> >>      setTimeout("timeExam()", 2000);
> >>      alert("return_yn = " + return_yn);
> >>      return return_yn;
> >> }
> >> </script>
> >>
> >>
> >>
> >>
> >> Is there a way to escape "from here ~ to here". If the form can be
> >> submit when calling ajax.url, I will not need to say:
> >>
> >> check_oprAction.action?tag1=...&tag2=...&tag3=... ...tag300=.
> >>
> >>
> >> See the problem I had is I do not want to do
> >> "?tag1=...&tag2=...&tag3=... ...tag300=. " through javascript, but only
> >> submit "check_oprAction"
> >>
> >> This is just an example.
> >>
> >> Thank you,
> >> --
> >> Lu Ying
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >   		 	   		
> 
> 
> -- 
> Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
> emilu@encs.concordia.ca        +1 514 848-2424 x5884
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
 		 	   		  

Re: jquery + struts2 + form validation

Posted by Emi Lu <em...@encs.concordia.ca>.
Hi Adam,

You provided the info exactly what I need!

Thank you very much!

For users had same question:
http://api.jquery.com/serialize/

Only one concern:  "var str = $("form").serialize();" in the online doc 
will not cause any performance issue if lots of (hidden)tags in the 
form, right?

--
Lu Ying


On 03/04/2011 12:38 PM, adam pinder wrote:
>
>
>
> jquery has built in ability to submit form elements in an ajax request
> for example
> 	$.post("AddUser_execute.action", $("#AddUserForm").serialize(),	   function(data){	   		cursor_clear();	     $('#P4_AddUser').html(data);	   }, "html");
>
> this statement will post to AddUser action and all form elements in the AddUserForm will be sent - the serialize method does the name/value pairing for you
> adam
>
>> Date: Fri, 4 Mar 2011 11:18:17 -0500
>> From: emilu@encs.concordia.ca
>> To: davelnewton@gmail.com
>> CC: user@struts.apache.org
>> Subject: Re: jquery + struts2 + form validation
>>
>> Hi Dave,
>>
>>>> check_action()
>>>> {
>>>>        PrintWriter out          = res.getWriter();
>>>>        res.setContentType("text/html");
>>>>        if(error)
>>>>        {
>>>>           out.println("<li>Error info</li>");
>>>
>>> Ew.
>>
>> What Ew means?
>>
>>>> The part gives me headache is that how to submit hundreds of tags in the
>>>> form in JSP?
>>>
>>> A form with hundreds of fields is a horrible mess anyway.
>>
>> It depends on the usage. We have search table default only several
>> fields shown. Users are allow to grab and display all hidden fields and
>> search based on those criteria.
>>
>>
>>
>>>> Is there a way, form values can be submit automatically?
>>>
>>> ... By submitting the form? You're going to have to be more specific
>>> in your requirements--I don't know what you mean by "can the form
>>> values be submit[ted] automatically"--that's what a form submission
>>> does, submits all the input elements in a form.
>>
>> An example:
>> ==============================
>> <s:submit action="saveRecord" onclick="return checkRecord()">
>>
>> Before real saving the the record into DB, check is done first.
>>
>> The checking is against DB operation.
>>
>> The jquery method checkRecord() has to say for example:
>>
>> <script type="text/javascript">
>> function  checkRecord()
>> {
>> //======================= from here ===============================
>>      var checkbox_value = "";
>>      for(var i=0; i<  document.form.checkbox_value.length; i++)
>>      {
>>           if(document.form.checkbox_value[i].checked)
>> 	{
>> 	   checkbox_value +=
>> "checkbox_value="+document.form.checkbox_value[i].value +"&";
>> 	}
>>      }
>>      if(checkbox_value != "")
>>      {
>>       checkbox_value = "?" + checkbox_value;
>>       checkbox_value = checkbox_value.substring(0, checkbox_value.length
>> -1);
>> }
>> 	
>> //======================= to here ===============================
>> var return_yn = false;
>> $.ajax({	
>>      async: false,
>>      url : "check_oprAction.action" + checkbox_value,
>>      success: function(data)
>>      {
>> 	   if(data==1)
>> 		{
>> 		   return_yn = true;
>> 		}
>> 	   else
>> 	   {
>>            $("#action_error_div").html(data);
>>            $("#action_error_div").removeClass().addClass("errormsg");
>>            return_yn = false;
>> 	   }
>>      }
>> });
>>      setTimeout("timeExam()", 2000);
>>      alert("return_yn = " + return_yn);
>>      return return_yn;
>> }
>> </script>
>>
>>
>>
>>
>> Is there a way to escape "from here ~ to here". If the form can be
>> submit when calling ajax.url, I will not need to say:
>>
>> check_oprAction.action?tag1=...&tag2=...&tag3=... ...tag300=.
>>
>>
>> See the problem I had is I do not want to do
>> "?tag1=...&tag2=...&tag3=... ...tag300=. " through javascript, but only
>> submit "check_oprAction"
>>
>> This is just an example.
>>
>> Thank you,
>> --
>> Lu Ying
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>   		 	   		


-- 
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
emilu@encs.concordia.ca        +1 514 848-2424 x5884

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: jquery + struts2 + form validation

Posted by adam pinder <ap...@hotmail.co.uk>.


jquery has built in ability to submit form elements in an ajax request
for example
	$.post("AddUser_execute.action", $("#AddUserForm").serialize(),	   function(data){	   		cursor_clear();	     $('#P4_AddUser').html(data);	   }, "html");

this statement will post to AddUser action and all form elements in the AddUserForm will be sent - the serialize method does the name/value pairing for you
adam

> Date: Fri, 4 Mar 2011 11:18:17 -0500
> From: emilu@encs.concordia.ca
> To: davelnewton@gmail.com
> CC: user@struts.apache.org
> Subject: Re: jquery + struts2 + form validation
> 
> Hi Dave,
> 
> >> check_action()
> >> {
> >>       PrintWriter out          = res.getWriter();
> >>       res.setContentType("text/html");
> >>       if(error)
> >>       {
> >>          out.println("<li>Error info</li>");
> >
> > Ew.
> 
> What Ew means?
> 
> >> The part gives me headache is that how to submit hundreds of tags in the
> >> form in JSP?
> >
> > A form with hundreds of fields is a horrible mess anyway.
> 
> It depends on the usage. We have search table default only several 
> fields shown. Users are allow to grab and display all hidden fields and 
> search based on those criteria.
> 
> 
> 
> >> Is there a way, form values can be submit automatically?
> >
> > ... By submitting the form? You're going to have to be more specific
> > in your requirements--I don't know what you mean by "can the form
> > values be submit[ted] automatically"--that's what a form submission
> > does, submits all the input elements in a form.
> 
> An example:
> ==============================
> <s:submit action="saveRecord" onclick="return checkRecord()">
> 
> Before real saving the the record into DB, check is done first.
> 
> The checking is against DB operation.
> 
> The jquery method checkRecord() has to say for example:
> 
> <script type="text/javascript">
> function  checkRecord()
> {
> //======================= from here ===============================
>     var checkbox_value = "";
>     for(var i=0; i < document.form.checkbox_value.length; i++)
>     {
>          if(document.form.checkbox_value[i].checked)
> 	{
> 	   checkbox_value += 
> "checkbox_value="+document.form.checkbox_value[i].value + "&";
> 	}
>     }
>     if(checkbox_value != "")
>     {
>      checkbox_value = "?" + checkbox_value;
>      checkbox_value = checkbox_value.substring(0, checkbox_value.length 
> -1);
> }
> 	
> //======================= to here ===============================
> var return_yn = false;
> $.ajax({	
>     async: false,
>     url : "check_oprAction.action" + checkbox_value,
>     success: function(data)
>     {
> 	   if(data==1)
> 		{
> 		   return_yn = true;
> 		}
> 	   else
> 	   {
>           $("#action_error_div").html(data);
>           $("#action_error_div").removeClass().addClass("errormsg");
>           return_yn = false;
> 	   }
>     }
> });
>     setTimeout("timeExam()", 2000);
>     alert("return_yn = " + return_yn);
>     return return_yn;
> }
> </script>
> 
> 
> 
> 
> Is there a way to escape "from here ~ to here". If the form can be 
> submit when calling ajax.url, I will not need to say:
> 
> check_oprAction.action?tag1=...&tag2=...&tag3=... ...tag300=.
> 
> 
> See the problem I had is I do not want to do 
> "?tag1=...&tag2=...&tag3=... ...tag300=. " through javascript, but only 
> submit "check_oprAction"
> 
> This is just an example.
> 
> Thank you,
> --
> Lu Ying
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
 		 	   		  

Re: jquery + struts2 + form validation

Posted by Emi Lu <em...@encs.concordia.ca>.
Hi Dave,

>> check_action()
>> {
>>       PrintWriter out          = res.getWriter();
>>       res.setContentType("text/html");
>>       if(error)
>>       {
>>          out.println("<li>Error info</li>");
>
> Ew.

What Ew means?

>> The part gives me headache is that how to submit hundreds of tags in the
>> form in JSP?
>
> A form with hundreds of fields is a horrible mess anyway.

It depends on the usage. We have search table default only several 
fields shown. Users are allow to grab and display all hidden fields and 
search based on those criteria.



>> Is there a way, form values can be submit automatically?
>
> ... By submitting the form? You're going to have to be more specific
> in your requirements--I don't know what you mean by "can the form
> values be submit[ted] automatically"--that's what a form submission
> does, submits all the input elements in a form.

An example:
==============================
<s:submit action="saveRecord" onclick="return checkRecord()">

Before real saving the the record into DB, check is done first.

The checking is against DB operation.

The jquery method checkRecord() has to say for example:

<script type="text/javascript">
function  checkRecord()
{
//======================= from here ===============================
    var checkbox_value = "";
    for(var i=0; i < document.form.checkbox_value.length; i++)
    {
         if(document.form.checkbox_value[i].checked)
	{
	   checkbox_value += 
"checkbox_value="+document.form.checkbox_value[i].value + "&";
	}
    }
    if(checkbox_value != "")
    {
     checkbox_value = "?" + checkbox_value;
     checkbox_value = checkbox_value.substring(0, checkbox_value.length 
-1);
}
	
//======================= to here ===============================
var return_yn = false;
$.ajax({	
    async: false,
    url : "check_oprAction.action" + checkbox_value,
    success: function(data)
    {
	   if(data==1)
		{
		   return_yn = true;
		}
	   else
	   {
          $("#action_error_div").html(data);
          $("#action_error_div").removeClass().addClass("errormsg");
          return_yn = false;
	   }
    }
});
    setTimeout("timeExam()", 2000);
    alert("return_yn = " + return_yn);
    return return_yn;
}
</script>




Is there a way to escape "from here ~ to here". If the form can be 
submit when calling ajax.url, I will not need to say:

check_oprAction.action?tag1=...&tag2=...&tag3=... ...tag300=.


See the problem I had is I do not want to do 
"?tag1=...&tag2=...&tag3=... ...tag300=. " through javascript, but only 
submit "check_oprAction"

This is just an example.

Thank you,
--
Lu Ying


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: jquery + struts2 + form validation

Posted by Dave Newton <da...@gmail.com>.
On Fri, Mar 4, 2011 at 10:44 AM, Emi Lu <em...@encs.concordia.ca> wrote:
> check_action()
> {
>      PrintWriter out          = res.getWriter();
>      res.setContentType("text/html");
>      if(error)
>      {
>         out.println("<li>Error info</li>");

Ew.

> The part gives me headache is that how to submit hundreds of tags in the
> form in JSP?

A form with hundreds of fields is a horrible mess anyway.

> Is there a way, form values can be submit automatically?

... By submitting the form? You're going to have to be more specific
in your requirements--I don't know what you mean by "can the form
values be submit[ted] automatically"--that's what a form submission
does, submits all the input elements in a form.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


jquery + struts2 + form validation

Posted by Emi Lu <em...@encs.concordia.ca>.
Good morning,

A question about struts2 + jquery form validation:

in jsp:
=========
<form>
... ... lots of tags
   <s:submit action1 onclick="return check_action()">
   <s:submit action2>
   <s:submit action3>
</form>

If check_action returns false, action1 will never be called!

JAVA action
================
private InputStream inputStream;

check_action()
{
    check tag1 against DB;  //whether dup, wrong info etc
    check tag2 against DB;
    ... ...

       PrintWriter out          = res.getWriter();
       res.setContentType("text/html");
       if(error)
       {
          out.println("<li>Error info</li>");
           ...
       }
       else
       {
          out.println(1);
       }
       out.flush();
       return SUCCESS;
}

The part gives me headache is that how to submit hundreds of tags in the 
form in JSP?

I do not want to use action?tag1=..&tag2=.. ... tag300=....

Is there a way, form values can be submit automatically?

Thanks a lot!
-- 
Lu Ying




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 list all the parameters

Posted by Kiwi209 <ki...@yahoo.fr>.

Thanks for your response, the problem is that I don't know all the
parameters set in the Action... So I would like to retrieve the list of all
the request parameters as name / value list.

(sorry for my english but it's not my natural tongue)
-- 
View this message in context: http://old.nabble.com/Struts2-list-all-the-parameters-tp31061470p31062904.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 list all the parameters

Posted by Dave Newton <da...@gmail.com>.
On Thu, Mar 3, 2011 at 1:37 PM, Kiwi209 wrote:
> Does anyone know how to get on a JSP page the list of all the parameters
> available on this page ?

What type of parameters? Request parameters? Via the request or a
ParametersAware (or whatever that's called, the one with the map)
action.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org