Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts and javascript problem" Watch "struts and javascript problem" New topic
Author

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
Bartender

Joined: Feb 26, 2001
Posts: 4456
    
    6

Originally posted by cb poo:
onfiltered="SearchPopup('<%=PopUp_url%>/App_Search.jsp');"/>


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.
 
Don't get me started about those stupid light bulbs.
 
subject: struts and javascript problem