aspose file tools*
The moose likes Struts and the fly likes Pop-up in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pop-up in struts" Watch "Pop-up in struts" New topic
Author

Pop-up in struts

Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
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

Joined: Jun 23, 2004
Posts: 85
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
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
??
action /javascript:window


please check config in struts-config.xml , All Corect


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
I think struts-config is correct:

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

Joined: May 21, 2004
Posts: 2
Try this <html:link action="..." target="_blank">My Link </html:link>

Cheers,
David
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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 ]

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
David Solera
Greenhorn

Joined: May 21, 2004
Posts: 2
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
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Miguel, could you post the tag you originally tried to open the pop-up window? (purely out of interest)
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
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

Joined: Jun 23, 2004
Posts: 85
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
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Ok. And it works as it should. How does the pop-up JSP's source itself look like?
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
It just accesses a bean and writes its properties...
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
And those bean property accesses fail?
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
It doesn't reach that point
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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

Joined: Jun 23, 2004
Posts: 85
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

Joined: Jul 04, 2003
Posts: 1312
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

Joined: Jun 23, 2004
Posts: 85
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

Joined: Jul 04, 2003
Posts: 1312
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.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

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


Junilu - [How to Ask Questions] [How to Answer Questions]
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
I'll post it tomorrow morning, I don't have the code here
thanks
forum guest
Greenhorn

Joined: Mar 24, 2003
Posts: 16
Miguel,
In your struts-config.xml


Shouldn't path be "/verproyecto.do"?
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
No. That doesn't matter...
Thanks
Miguel Flecha
Ranch Hand

Joined: Jun 23, 2004
Posts: 85
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>
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341

<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

Joined: Jun 23, 2004
Posts: 85
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

Joined: Jun 23, 2004
Posts: 85


Solved!! That was the problem
Thanks to all
Andrew Leung
Greenhorn

Joined: Aug 05, 2004
Posts: 2
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
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

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

Joined: Jun 23, 2004
Posts: 85
Maybe a slash missing??

<forward name="viewMultipleDocs" path="/ViewMultipleDocsFrame.jsp" />
Andrew Leung
Greenhorn

Joined: Aug 05, 2004
Posts: 2
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

Joined: Jun 23, 2004
Posts: 85
Congratulations!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pop-up in struts