Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts and javascript problem

 
cb poo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
cb poo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, it is working.
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic