• 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

Pop-up in struts

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I'm trying to open a popup when the user clicks a link. From that link I want to call an action, passing it a parameter and display the results in the pop-up window
Could you help me?
Regards
Miguel
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got to open the pop-up correctly, but the content of the popup is not displayed. I get the following exception:

org.apache.jasper.JasperException: Cannot retrieve mapping for action /javascript:window

Do you guys know why?
Thanks
Miguel
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
??

action /javascript:window



please check config in struts-config.xml , All Corect
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think struts-config is correct:

<action path="/verproyecto" type="ibt.struts.action.VerProyectoAction" validate="false">
<forward name="proyecto" path="/popup/proyecto.jsp"/>
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this <html:link action="..." target="_blank">My Link </html:link>

Cheers,
David
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would definitely consider whether David's suggestion (regular link which happens to open in a new window) is acceptable. Another way might be to use a plain old HTML link (<a href=...> instead of the Struts <html:link> taglib. The latter would let you use JavaScript's window.open() and specify things like pop-up size, etc.
[ July 27, 2004: Message edited by: Lasse Koskela ]
 
David Solera
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you also can use this (to keep on using struts taglibs ):
<html:link href="javascript:window.open();"> The link </html:link>

Cheers, david
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Miguel, could you post the tag you originally tried to open the pop-up window? (purely out of interest)
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have the code here, but I'm using <a href="openWindow(param)">Popup</a>

and I define a function called openWindow that uses window.open(....)

I didn't use the target="_blank" because I want a popup window without menu bar, etc.

The popup is opened perfectly, but the problem comes when the action returns the control to the jsp...

I'll post the complete sentence tomorrow morning
Regards
Miguel
[ July 27, 2004: Message edited by: Miguel Flecha ]
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!

This is the how I open the popup:

<a href="javascript penWindow('<bean:write name="codigo"/>')"><bean:write name="codigo"/></a>

This is the function

<script language="JavaScript">
function openWindow(param) {
var url = "<%=response.encodeURL("/defaultroot/verproyecto.do?codigo=")%>" + param ;
window.open(url,'','width=350,height=350,top=134,left=262,resizable=1,scrollbars=1');
}
</script>

And this is the mapping in the struts-config.xml:

<action path="/verproyecto" type="ibt.struts.action.VerProyectoAction" validate="false">
<forward name="proyecto" path="/popup/proyecto.jsp"/>

I hope you can help me
Thanks a lot
Miguel
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. And it works as it should. How does the pop-up JSP's source itself look like?
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It just accesses a bean and writes its properties...
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And those bean property accesses fail?
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't reach that point
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this
org.apache.jasper.JasperException: Cannot retrieve mapping for action /javascript:window
is displayed in the pop-up window, I suppose you're trying to use the <html:link> tag with some JavaScript in the attributes?
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using an <a href="...."> with a javascript inside, but that's the way to do it,isn't it?
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Discussion of Popup in Struts Framework

http://www.theserverside.com/discussions/thread.tss?thread_id=27036


Struts Error taglib

http://www.servletsuite.com/servlets/strutserrortag.htm
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That doesn't help :-(
The problem is with the forward in the struts-config, as the program enters the action without problems and finds a problem when returning back to the popup jsp
Thanks anyway
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Miguel Flecha:
The problem is with the forward in the struts-config, as the program enters the action without problems and finds a problem when returning back to the popup jsp
Thanks anyway




So, you should be keep all data to session or application scope for display in popup window, i think m it is one solution to solve this problem.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks to me like the problem is in proyecto.jsp. If it's not too long, post it, or at least the parts where you have either an html:form or html:link that references javascript:window
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll post it tomorrow morning, I don't have the code here
thanks
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Miguel,
In your struts-config.xml


Shouldn't path be "/verproyecto.do"?
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. That doesn't matter...
Thanks
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is proyecto.jsp:


<%@ page language="java"%>

<%@ taglib uri="struts-bean" prefix="bean"%>
<%@ taglib uri="struts-html" prefix="html"%>
<%@ taglib uri="struts-tiles" prefix="tiles"%>

<html:html>

<head>
<link rel="stylesheet" type="text/css" href="images/estilo.css">
<title><bean:message key="proyecto.title"/></title>
</head>

<body>
<center><h2><bean:message key="proyecto.main"/></h2>
<br/>
<table width="80%">
<tr>
<td align="left"><bean:message key="proyecto.nombre"/></td>
<td align="left"><bean:write name="proyecto" property="nombre"/></td>
</tr>
<tr>
<td align="left"><bean:message key="proyecto.codigo"/></td>
<td align="left"><bean:write name="proyecto" property="codigo"/><td>
</tr>
<tr>
<td align="left"><bean:message key="proyecto.cliente"/></td>
<td align="left"><bean:write name="proyecto" property="cliente"/></td>
</tr>
<tr>
<td align="left"><bean:message key="proyecto.creacion"/></td>
<td align="left"><bean:write name="proyecto" property="creacion"/></td>
</tr>
<tr>
<td align="left"><bean:message key="proyecto.main"/></td>
<td align="left"><logic:equal name="proyecto" property="estado" value="0"><bean:message key="proyecto.inactivo"/></logic:equal>
<logic:equal name="proyecto" property="estado" value="1"><bean:message key="proyecto.activo"/></logic:equal>
</td>
</tr>
</table>
<html:form action="javascript:window.close();">
<html:submit><bean:message key="proyecto.cerrar"/></html:submit>
</html:form>

</center>
</body>
</html:html>
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


<a href="javascript openWindow('<bean:write name="codigo"/>')"><bean:write name="codigo"/></a>



<bean:write name="codigo" property=???>

What is its perperty?
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
codigo is not a bean, is just a String, but you can access it that way.
In case of having a bean you should use the property attribute.
Thanks anyway
Miguel
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Solved!! That was the problem
Thanks to all
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am experiencing the same problem and wonder if you could explain how you resolved your problem? I have a similar situation that a popup calls an Action, and then a problem occurs at the time of forward.

fyi, this is the url in the popup:
http://localhost:8019/eSystem/documents/a2506d/viewDoc.do?navigation=viewDoc

and this is in the struts-config.xml:
<action path="/documents/.*/viewDoc"
type="com.es.actions.ViewDocAction"
scope="session"
name="OrderDetailForm"
parameter="navigation">
<forward name="viewMultipleDocs" path="ViewMultipleDocsFrame.jsp" />
</action>

and this is the last line in my action:
return mapping.findForward("viewMultipleDocs");

and I got a system error on the my popup after the above line

thx

andrew
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andrew, is the error being displayed in the popup window or in the main window that brings up the popup? If your error is in the popup window, then your issue is different from Miguel's. The problem that he had would have caused an error to occur in the main window that had the link for the popup.
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe a slash missing??

<forward name="viewMultipleDocs" path="/ViewMultipleDocsFrame.jsp" />
 
Andrew Leung
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx, that's what i found too.

i ended up having to make 2 changes for my application to work.

1) add a leading '/' to the forward path in struts-config.xml

2) the forward target jsp, which is really a simple html frame with src='/myDomain/viewDoc.do', has to be changed to 'viewDoc.do'

to complicate things even more, after applying change#1 alone, my application would work on Tomcat, but instead got a 404 on weblogic. Change#2 is needed for it to work correctly on weblogic.

andrew
 
Miguel Flecha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulations!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic