Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cant get JSP code to work inside layer  RSS feed

 
Jennifer Johnson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help! I am trying to mix javascript and java together...difficult I know. Well I have an onClick() that shows a layer and I need this layer to call a bean and get the info and display in an drop down menu (html). here is my code for the call to the layer:

<DIV onclick='event.cancelBubble = true;' class=popup id=reportFieldPopup><b>My Selections</b> <input type=hidden name=repName><select name="Favorites">
<jsp:setProperty name="valrep" property="repName" />
<%
valrep.FavReports();
out.println("23");
cnt = valrep.getSize();
FavName = valrep.getItems();
for (i=0;i<FavName.size();i++){
%>

<option><%=FavName.get(i)%></option>

<%}%>
</select>
</form>
FN=<%=FavName.size()
%>
[<a class=closeLink href='#' onclick='hideCurrentPopup(); return false;'>Close </a>]</DIV>


However...it does not call the bean...but it does set the property. Can anyone help!!!
Thanks!
------------------
Jen
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you have to remember this distinction:
JSP/Java code executes on the server
HTML/JavaScript renders/executes on the client (browser).
To get your bean called you have to have some sort of process of submitting the data back to the server.
Hopefully this will make your problem more clear.
James.
 
Jennifer Johnson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I submit the form with out refreshing the page? I would like to submit the variable to the bean but still keep the same page...maybe just change the layer? Is that possible?
Thanks for your help!

------------------
Jen
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on how complex a solution you want.
1) the easiest is to just submit the current page and build it again from the server
or more complex
2) setup a frameset that has your display page plus a hidden frame (define it to take up no space in the frameset). This hidden frame can then be used to submit data to the server seamlessly without the user knowing about it.
ie. pseudo-code:
- get the handle for the hidden frame via javascript (something like document.parent.frames["hiddenFrame'])
- build some sort of query string containing the data you want to send back via the hidden frame (myJsp?myData=...) with javascript
- submit the hidden frame
- the page that comes back from the server must has some JavaScript defined functions to update your display page with data from your JavaBean
I have successfully done this before but probably haven't explained it very well.
Let me know if you need more detail.
James.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!