struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "raghu_c" <ragh...@infosys.com>
Subject RE: Submit issue for new form with struts
Date Fri, 06 Jun 2003 05:23:41 GMT
Ya , this works 

however, the params are displayed in the url as request parameters + are editable 
(if u do a Ctrl-N on the popup window)
No, i do not want to disable a ctrl-N or anything

what i was looking for is a way to 
push the params into my Form Bean using their property methods (setters)
and then just submit the form (open the popup)

The form bean of the other jsp can then get the parameters - all happening on server side

is that possible?
Raghu

-----Original Message-----
From: James Mitchell [mailto:jmitchell@apache.org]
Sent: Thursday, June 05, 2003 8:09 PM
To: Struts Users Mailing List
Subject: Re: Submit issue for new form with struts


Ok, I think I've got what you were looking for.

This script uses a link to set hidden fields which are submitted to your
customized window (hidden toolbar, etc).

You can copy and paste this as a simple jsp to test.  I've added some
debugging (snoop) stuff at the bottom just to verify that the params were
passed correctly.

Let me know if this helps or if you need more help tweaking it.

----------------------------------------------------------------------
<form name="frm2" action="?" method="GET">
<table border="1">
 <tr>
  <td>
   <a href="#" onclick="fnOpenDetails(1, 'IS41')">Sample Data 1</a>
  </td>
  <td>
   more stuff
  </td>
 </tr>
 <tr>
  <td>
   <a href="#" onclick="fnOpenDetails(2, 'IS41')">Sample Data 2</a>
  </td>
  <td>
   more stuff
  </td>
 </tr>
</table>
<input type="submit" name="sbmt" value="Submit">
<input type="hidden" name="intRecordCount" value="xxx">
<input type="hidden" name="strMessageCategory" value="xxx">

</form>

<script>
function fnOpenDetails(RecNum, msgCategory){
 var newWindow;
 newWindow = window.open("", 'Detailswindow',
'width=700,height=600,toolbar=no,scrollbars=yes,resizable=no');

//window.open("MinEsnDetailsGeneral.do",'Detailswindow','width=700,height=60
0');
 document.forms[0].target='Detailswindow';
 document.forms[0].elements["intRecordCount"].value = RecNum;
 document.forms[0].elements["strMessageCategory"].value = msgCategory;
 document.forms[0].submit();
 return false;
}

</script>



<pre>
<%

java.util.Enumeration enum = null;
ServletContext context = getServletContext();

try{
 out.println("<h3>Servlet init parameters</h3>");
 enum = getInitParameterNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  String value = getInitParameter(key);
  out.println("   " + key + " = " + value);
 }
}
catch(Exception e){
  //continue
}

try{
 out.println("<h3>Context init parameters</h3>");
 enum = context.getInitParameterNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  Object value = context.getInitParameter(key);
  out.println("   " + key + " = " + value);
 }
}
catch(Exception e){
  //continue
}

try{
 out.println("<h3>Context attributes</h3>");
 enum = context.getAttributeNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  Object value = context.getAttribute(key);
  out.println("   " + key + " = " + value);
 }
}
catch(Exception e){
  //continue
}

try{
 out.println("Request attributes:");
 enum = request.getAttributeNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  Object value = request.getAttribute(key);
  out.println("   " + key + " = " + value);
 }
}
catch(Exception e){
  //continue
}


try{
 //java.util.Enumeration
 enum = request.getHeaderNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  String value = request.getHeader(key);
  out.println("   <b>" + key + "</b>: " + value);
 }
}
catch(Exception e){
  //continue
}


out.println("Servlet Name: " + getServletName());
out.println("Protocol: " + request.getProtocol().trim());
out.println("Scheme: " + request.getScheme());
out.println("Server Name: " + request.getServerName());
out.println("Server Port: " + request.getServerPort());
out.println("Server Info: " + getServletContext().getServerInfo());
out.println("Remote Addr: " + request.getRemoteAddr());
out.println("Remote Host: " + request.getRemoteHost());
out.println("Character Encoding: " + request.getCharacterEncoding());
out.println("Content Length: " + request.getContentLength());
out.println("Content Type: "+ request.getContentType());
out.println("Locale: "+ request.getLocale());
out.println("Default Response Buffer: "+ response.getBufferSize());
out.println("Request Is Secure: " + request.isSecure());
out.println("Auth Type: " + request.getAuthType());
out.println("HTTP Method: " + request.getMethod());
out.println("Remote User: " + request.getRemoteUser());
out.println("Request URI: " + request.getRequestURI());
out.println("Context Path: " + request.getContextPath());
out.println("Servlet Path: " + request.getServletPath());
out.println("Path Info: " + request.getPathInfo());
out.println("Path Trans: " + request.getPathTranslated());
out.println("Query String: " + request.getQueryString());


try{
 out.println("Parameter names in this request:");
 //java.util.Enumeration
 enum = request.getParameterNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  String[] values = request.getParameterValues(key);
  out.print("   " + key + " = ");
  for(int i = 0; i < values.length; i++) {
   out.print(values[i] + " ");
  }
  out.println();
 }
}
catch(Exception e){
  //continue
}



try{
 out.println("<h3>Request Headers</h3>");
 //java.util.Enumeration
 enum = request.getHeaderNames();
 while (enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  String value = request.getHeader(key);
  out.println("   " + key + ": " + value);
 }
}
catch(Exception e){
  //continue
}


try{
 out.println("<h3>Cookies</h3>");
 Cookie[] cookies = request.getCookies();
 for (int i = 0; i < cookies.length; i++) {
  Cookie cookie = cookies[i];
  out.println("   " + cookie.getName() + " = " + cookie.getValue());
 }
}
catch(Exception e){
  //continue
}


try{
 out.println("<h3>Session data</h3>");
 out.println("Requested Session Id: " + request.getRequestedSessionId());
 out.println("Current Session Id: " + session.getId());
 out.println("Session Created Time: " + session.getCreationTime());
 out.println("Session Last Accessed Time: " +
session.getLastAccessedTime());
 out.println("Session Max Inactive Interval Seconds: " +
session.getMaxInactiveInterval());
 out.println("Session scoped attributes:");
 enum = session.getAttributeNames();
 while (enum.hasMoreElements()) {
  String name = (String) enum.nextElement();
  out.println("   " + name + " = " + session.getAttribute(name));
 }
}
catch(Exception e){
  //continue
}



%>
</pre>


--
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx


----- Original Message ----- 
From: "raghu_c" <raghu_c@infosys.com>
To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
Sent: Thursday, June 05, 2003 9:05 AM
Subject: RE: Submit issue for new form with struts


Ya,

have a hard coded .do

the documnt.forms['frm'].submit throws a object doesnt support method or
property
when used in conjunction with struts - it works fine with plain ol' html

essentially this is what i wish to do

<script>
function fnOpenDetails(RecClicked,RecNum)
{
var msgCategory = 'IS41';
RecSelected.className="ResultRow";
RecClicked.className="SelRow";
RecSelected=RecClicked;
RowClicked=RecNum;
document.forms[0].intRecordCount.value=RecNum
document.forms[0].strMessageCategory.value = msgCategory
document.forms[0].submit();
window.open("MinEsnDetailsGeneral.do",'Detailswindow','width=700,height=600'
)
}

</script>

I am unable to push the values i am setting in the script - eg
intRecordCount
into my FormBean
so i need a submit

??

Raghu


> essentially a table of values (list of records) retrieved from the
> db - on the action of the first jsp
> on dbl clicking the list,

That still doesn't answer the question about text or text boxes, so for now
I'll assume this is text.

> i have a javascript function that captures the record index
> and tries opening another window(a popup type) that queries the db for
> further data based on the record dbl clicked,

ok.

>
> As of now, I am able to configure the submit by giving the
action="/popupdetails.do"
> instead of plain action="popupdetails" (w/o the '.do')
> this somehow calls the execute method of the corresponding action class!!

So you've hard-coded ".do" on your page?

>
> now, i have a different issue  :(
> i want to pass the record index into the popupdetails jsp
> and i do not want to construct a url with a request parameter since that
makes the url editable and all.
>
> i thought i will use a property of the originating jsp formbean to hold
the record index
> (of the dblclicked record - hidden variable and all)
> my doubt is : how can one set a property in the bean on dblclick of the
record?

I posted some sample html yesterday that (almost) demonstrates how to do
this:

<form name="frm" action="?same-page" method="GET">
<input type="hidden" name="action" value=""/>
<input type="checkbox" name="users" value="Test1">Test1<br>
<input type="checkbox" name="users" value="Test2">Test2<br>
<input type="checkbox" name="users" value="Test3">Test3<br>
<input type="checkbox" name="users" value="Test4">Test4<br>
<input type="checkbox" name="users" value="Test5">Test5<br>

<br>
<a href="JavaScript:doForm('users.actions.add')">Add</a> |
<a href="JavaScript:doForm('users.actions.delete')">Remove</a>
</form>

<script>
function doForm(action){
  document.forms['frm'].elements['action'].value=action;
  document.forms['frm'].submit()
}

</script>


...modify this to work for your situation:
- add target="_new" to the form
 or
- open your new window (with params) from the doForm function


>
> Or is there an alternative?
>
> Thanx in Advance,
> Raghu
>
>

HTH

--
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org
770-822-3359
AIM:jmitchtx


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


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


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


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


Mime
View raw message