wood burning stoves 2.0*
The moose likes Applets and the fly likes Possible to pass a run time param? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Possible to pass a run time param?" Watch "Possible to pass a run time param?" New topic
Author

Possible to pass a run time param?

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

The jsp :p arams tags must occur within the object tag.
[ May 09, 2005: Message edited by: Joe Ess ]

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

How are you getting the data to the JSP? Servlet setting an attribute? Request parameter? System parameter?
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

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

Joined: Aug 04, 2003
Posts: 276
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

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

Joined: Aug 04, 2003
Posts: 276
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!
 
Consider Paul's rocket mass heater.
 
subject: Possible to pass a run time param?
 
Similar Threads
Argh....all I want to do is load this applet..
Reg: Running Swing in Browser
Problems when initiating applet for jre1.4.2 when jre1.5 is on the client
Runtime parameter changes
3 problems with my applet...