java - Alert Message is not displaying when i click h:command button in xhtml -


The warning message is not showing when I click on the button. If I click on a button, it should show a warning message as a success with a delay of 3 minutes.

When I click on the button, first it is not responding second time to get value from Bean Why the reason for the first time is not being loaded, what is the reason?

XHTML code:

  & lt; Html xmlns = "http://www.w3.org/1999/xhtml" xmlns: h = "http: // xmlns .jcp.org / JSF / html" & gt; & Lt; H: top & gt; & Lt; Title & gt; Facet & lt; / Title & gt; & Lt; Script & gt; Var myVar; Function myFunction () {myVar = setTimeout (function () {message ();}, 3000); } Function message () {myVar = setTimeout (function () (if (# {mytest.count} === 0} {warning ("failed");} and {warning ("success");}}, 3000) ;} & Lt; / script & gt; & lt; / h: top & gt; & lt; h: body & gt; & lt; h: form & gt; & lt; h: command button onclic = "message ( ); "Action =" # {mytest.func} "value =" click "/>   

Managed Bean Code:

  Package com.display; Import javax.faces.bean.ManagedBean; @ Managed Square Public Class Matest {Personal Inte Count = 0; public int getCount () {return calculation}; Public Zero SetCount (integer number) {this.count = count;} public zero func () {this.count = 1; System.out.println ("function called"); System.out.println ("The calculation value is - & Gt; "+ count);}}    

Something I wanted to say ( This can not be an answer, but I wanted to make some refactoring material that can help you solve this problem.)

1 If I click on a button I click on it to delay of 3 minutes Student Success should show the warning message.

But according to your code it is:

  myVar = settimeout (function () {message ();}, 3000); // 3 seconds (1000 ms = 1 second)   

2 . myvar is defined globally which is assigned both functions myFunction () and messages . I do not see any use of myvar in your code.

Edit

Actually, your javascript code is being applied before checking in to your Bean class if any of your command buttons incomplete can be .

Alternatively you can replace and with your & lt; H: Command button (gt; as

  & lt; f: ajax onevent = myFunction (); />    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -