File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts and javascript problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts and javascript problem" Watch "struts and javascript problem" New topic

struts and javascript problem

cb poo
Ranch Hand

Joined: Oct 02, 2002
Posts: 67
hi guys,
I managed to popup a window(SearchPopup in a _javascript function) with another page(Pop_up.jsp) using following command:

<INPUT class=BUTTON type=button name=btnSearch id=btnSearch value=Search style=cursor:hand onfiltered="SearchPopup('<%=PopUp_url%>/Pop_up.jsp');">

After change to below html:button code, page 404 showed in the pop up window. The <%=PopUp_url%> is not replace by the actual value when i view the properties of the PopUp Window. It is still <%=PopUp_url%>/Pop_up.jsp.

<html:button property="mode" value="Search" styleClass="BUTTON" style="cursor:hand" onfiltered="SearchPopup('<%=PopUp_url%>/App_Search.jsp');"/>

Could anyone tell me how to solve this? thank you.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6528

Originally posted by cb poo:

Should be something like:

onfiltered='<%= "SearchPopup(\'" + PopUp_url + "/App_Search.jsp\');" %>'

You can't "embed" a JSP expression in a literal value when it comes to custom tag attributes that take runtime expressions. In other words, instead of "literal <%= expr %> literal", it must be '<%= "literal" + expr + "literal" %>'.

Note: If escaping the single quotes with "\" doesn't work, try using two single quotes, i.e. "SearchPopup(''" + ... I'm not quite sure which form the JSP parsing will accept.
[ December 09, 2004: Message edited by: Junilu Lacar ]

Junilu - [How to Ask Questions] [How to Answer Questions]
cb poo
Ranch Hand

Joined: Oct 02, 2002
Posts: 67
yeah, it is working.
Thank you.
I agree. Here's the link:
subject: struts and javascript problem
It's not a secret anymore!