• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Possible to pass a run time param?

 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All I want to do is, at run time, supply a parameter to my applet.

Currently, the applet gets invoked from inside a JSP that looks like this:



I tried getting the "URL" value in the DisplayMonoApplet by doing a getParameter("URL") in the init method, but it returned null, so maybe the way I have the param set up (inside the jsp:parm tag) isn't the way it needs to be done, but iin any case, I still need to modify it at run time to supply data to the applet.

Does anyone know how to do this?

THANKS!
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jsp :p arams tags must occur within the object tag.
[ May 09, 2005: Message edited by: Joe Ess ]
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
The jsp arams tags must occur within the object tag.

[ May 09, 2005: Message edited by: Joe Ess ]


Thanks. I had them there at one time...don't remember why I moved them out.

Any clue about the runtime parameter thing?
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you getting the data to the JSP? Servlet setting an attribute? Request parameter? System parameter?
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for asking Joe.


OK, here is what is going on. This is a Sun Java Studio Creator application that builds Java Server Faces apps that, in this case at least, use JSP.

In JSF, you have a "backing bean" that works with each JSP. So, if I have a example1.jsp, I'll have an example1.java file as its page bean.

When you have a JSF component on the JSP, you will get a variable of that type in the backing bean.

For example, if example1.jsp had an image component called image1, then there would be an HtmlGraphicImage variable called image1 in the example1.java file.

The thing is, there are no related variables in the example1.java file for jsp params, so there should be a way to get to the parameter from within the backing bean (example1.java in this example). Once I have the param, I should be able to set its value.

Currently, all I have access to that I can see is form1.

Here is my new, slimmed down, JSP code where you can see the form1 and the jsp param more clearly:




What happens then is the applet gets loaded, and it looks at the URL parameter by doing a getParameter("URL"). The applet then will use that URL to call a servlet to load up a 3D image.

[ May 09, 2005: Message edited by: Darrin Smith ]
[ May 09, 2005: Message edited by: Darrin Smith ]
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Darrin Smith:
The thing is, there are no related variables in the example1.java file for jsp params, so there should be a way to get to the parameter from within the backing bean (example1.java in this example). Once I have the param, I should be able to set its value.


I've never worked with JSF but you don't need a variable for applet parameters in particular. You just need a variable in the backing object to get you some value. You can then set the applet parameter tag to that value. In Struts, one sets up this sort of thing by creating a class and telling Struts about it in the struts config XML file. I'm sure there's something similar for JSF.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:


I've never worked with JSF but you don't need a variable for applet parameters in particular. You just need a variable in the backing object to get you some value. You can then set the applet parameter tag to that value. In Struts, one sets up this sort of thing by creating a class and telling Struts about it in the struts config XML file. I'm sure there's something similar for JSF.



OK, now we are getting somewhere.

What I can do then is, in example1.java for example, add a String called urlString and create getURLString and setURLString methods for it.

In the JSP then, for my jsp:param name="URL" value="___" I just need to refer to the backing bean in some fashion (not sure how I get it just yet).

So, it will end up looking like this in the JSP:



Does that look about right?

THANKS!
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I'm thinking. You may want to pose this question in the Java Server Faces forum if you need help with the exact syntax..
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
That's what I'm thinking. You may want to pose this question in the Java Server Faces forum if you need help with the exact syntax..



I think the format is value="#{beanName.urlString}"

Thanks for all the help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic