-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re: executing javascript from java #6
Comments
You have to look the button's client ID in Firebug or Chrome Dev. Tool. (in HTML). If you know the full client ID, you can write (assume the full client ID is rc.execute("$('#mainForm_btn2').show();"); Please note the <p:commandButton id="btn2" styleClass="myButton" .../> and reference the button by this style class as follows: rc.execute("$('.myButton').show();"); Report here please if this that solved your problem and give us 5 stars on amazon :-) http://www.amazon.com/PrimeFaces-Cookbook-Edition-Mert-Caliskan/dp/1784393428 Thanks! |
Hi Oleg, Thanks for your prompt response !, but I am still stuck on this problem. I will post a 5-star comment on Amazon ! Cheers Ed On Thu, Jun 18, 2015 at 3:49 AM, Oleg Varaksin notifications@github.com
|
It is not possible to execute the JavaScript code BEFORE the view is rendered :-). The JS Code will be executed in DOM ready event. That mean short before window.onload. What is the problem exactly? Where do you have rc.execute(...)? It should be in a quite normally action in bean. |
Hi Oleg,Thanks for your comments regarding the fact that JavaScript code is executed after the view is rendered (I was not certain!). However, when I force the page reload in the managed bean by using the ExternalContext class, this seems to prevent the JavaScript code from executing (please see code below). On the opposite, if I remove the ExternalContext code lines from the bean, the JavaScript code is executed correctly, but the page is not reloaded and I need it to do so. Any suggestions welcome !
|
Ah, you're doing redirect to the same page. This will not work because these are two request then. POST (you action will be executed) - Response to the browser (JS will be executed) - GET (by reason of redirect) - Response to the browser. Why do you need a redirect? Can you not only use POST? Simple execute your action in bean with return value void. If you really need a redirect to another page, this another page should have a script block with JS logic (click on the btn2 button). See the book, the last chapter with examples. |
Hi Oleg, as requested find below my review I just posted on Amazon.com. Byeduardo kremer On Sat, Jun 20, 2015 at 2:51 PM, Oleg Varaksin notifications@github.com
|
[image: Amazon.com] Your Profile Account http://www.amazon.com/gp/css/homepage.html
Congratulations! Your review on Amazon has been posted to the site. |
Hi Oleg, Thanks for your comments ! they're pretty insightful. Ed On Sat, Jun 20, 2015 at 10:22 PM, Eduardo Kremer <
|
Thank you a lot too. I hope I could help you. You can also use our forum for any kind of questions http://forum.primefaces.org/viewforum.php?f=14 |
Hello Oleg !
I am currently engaged in developing a web project using PrimeFaces. I bought your cookbook (pretty insightful !). I am putting in practice some concepts shown on this book, but I cannot execute a javacript from java. In short, I need "to click a button from java". I debugged and logged it, checked the browser's console for errors (none), tried jQuery's different notations ($, jQuery, PF), but nothing. I also reviewed the page's source code and jQuery plugin is there. Any hints is welcome !
Thanks in advance,
Ed Kremer
user.xhtml
LoginController.java
The text was updated successfully, but these errors were encountered: