*
The moose likes JSF and the fly likes Runtime parameter changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Runtime parameter changes" Watch "Runtime parameter changes" New topic
Author

Runtime parameter changes

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Although this is sort of a JSP question, it goes along with the JSF app I'm building and has some reliance on that. Anyway, what I need to do is pass a parameter to an applet, and this parameter must be set at runtime. The parameter value will be known to the backing bean so I can set it in before render response, but how it is to be set (the code to do it) I'm not sure of.

Can this be done, and if so, how?

I was thinking that you need to add something like this to the JSP that loads the applet:




Assuming that is correct, how do I set the "URL" parameter from within my backing bean of the JSP page?

The full code looks like this:



[ May 09, 2005: Message edited by: Darrin Smith ]
[ May 09, 2005: Message edited by: Darrin Smith ]
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
request.setAttribute() inside the backing bean and request.getAttribute() in the JSP page. It should work isn't?

where, request is of HttpServletRequest type object.


- Varun
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
It might work, but I don't know how to do that. What I was thinking is that I need some sort of tag for my value field like this:


What you are saying though (using the request) is different, and I don't know how to incorporate that.

BTW, I did a little research into it, and although I didn't see any "request.getAttribute" I did find some info on pagecontext.getAttribute.

Also, I have tried value="%=BackingBeanName.urlValue%" and that gives me an error (Unable to compile JSP).

Thanks.
[ May 10, 2005: Message edited by: Darrin Smith ]
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Darrin Smith:
It might work, but I don't know how to do that.


You can get the HttpServletRequest object in your backing bean through ExternalContext class, you can see exact method in api.

In the JSP page, extract the value as you would do in any JSP page i.e.
value='<%=(String)request.getAttribute("param")%>'
[Sorry if I have used any bad syntax above, it been ages since I wrote pure JSP ]
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Thanks!

I'll give that a try and let you know how it goes.
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276


That won't work. I've tried it every way I can think of but it will not allow me to place a '<' inside a value parameter. It keeps saying:

The value of attribute "value" associated with an element type "jsp:param" must not contain the '<'character.

The last thing I tried was this:




This is driving me nuts!

Any more thoughts?

Thanks.
[ May 10, 2005: Message edited by: Darrin Smith ]
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Even the smileys aren't working

Can you show how your JSP looks like maybe just show all the parent tags of the jsp aram in your JSP file
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Here is the entire JSP with the value ommitted (it didn't work anyway!).



My backing bean (DisplayMonoApplet.java)has a property called urlValue which is a String declared like this:

private String urlValue;

public String getUrlValue()
{
return this.urlValue;
}

That's all there is to it really. The JSP just loads a plugin for an applet, and the applet needs to be told a URL at runtime. Simple...but I can't get it to work!

BTW, I really appreciate the help.
[ May 10, 2005: Message edited by: Darrin Smith ]
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Seems JSP + JSF does creates wonders at time. You might have to do bit of R&D
or alternatively store your URL value in an h utputText type JSF object and try javascript/applet communication to read/ pass the value in applet. I hope it's possible never tried though.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Javascript Applet Communication, if it can help.
Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
If you are using JSP 2.0/Servlet 2.4 (Tomcat 5), you could try EL. Like this:


As long as jsp:param allows EL in its attributes, it should work.
[ May 11, 2005: Message edited by: Henrique Sousa ]

Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Originally posted by Henrique Sousa:
If you are using JSP 2.0/Servlet 2.4 (Tomcat 5), you could try EL. Like this:


As long as jsp:param allows EL in its attributes, it should work.

[ May 11, 2005: Message edited by: Henrique Sousa ]


Thanks for trying, but that did not work either.

What it does is give me the exact test I put in as a literal string:
${DisplayMonoApplet.urlValue}

Boy, who ever dreamed up this JSP stuff?

Anyway, thank you for at least trying.
Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
Are you using Tomcat 5? If so, it seems that you have EL disabled. To enable Expression Language, include a page directive:

or change web.xml DTD to
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276

or change web.xml DTD to
[/qb]<hr></blockquote>


Well I've tried to get make the changes to the web.xml file, but it will not build (using the Java Studio Creator IDE) using what you have ( even though I verified that it should work...everyone else seems to use this).

Here is what is there now, and the only thing that seems to work:


So, how/where do you put the


into the JSP page? No matter how I did it, it was flagged as an error.

Thanks...and I really do appreciate the help.
[ May 11, 2005: Message edited by: Darrin Smith ]
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Update:

I changed from


to


in my jsp. It is my understanding that the default for 1.2 is true, but it is false for 2.0, so in effect I did what you wanted with this instead of using the

That still had no effect...the value is still treated as a literal.

So, now I have this:



When I run it, instead of seeing the URL value as http://.... it shows up as ${DisplayMonoApplet.urlValue}

Argh!


NEVER MIND WHAT I JUST SAID!

It looks like creator keeps defaulting back to 1.2 and changes the JSP automatically for me to that each time I save!

So, I have added the isELIgnored="false" to my jsp:directive.page...I'll see if that helps.
[ May 11, 2005: Message edited by: Darrin Smith ]
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
THAT WORKS!

Thank you very much!



Man what a struggle.

Now it's time to pass the word...a lot of other people were wondering about this too!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime parameter changes
 
Similar Threads
Possible to pass a run time param?
Argh....all I want to do is load this applet..
parameter to applet problems
Runtime parameter?
3 problems with my applet...