How to update a value displayed in the page without refreshing

前端 未结 2 642
刺人心
刺人心 2020-12-03 20:38

I have this 3 fields in a JSF page

 


        
2条回答
  •  有刺的猬
    2020-12-03 21:07

    If this is simple calculation, which doesn't need server call then you should go with client side javascript solution


    But As you love to do it using Ajax here you go..

    You can use and render attribute to make this thing happen using AJAX .

     
           
              
           
           
             
           
    
          
    
    

    @ManagedBean(name = "managedBean") 
    public class Bean { 
       private String val1; // getter and setter 
       private String val2; // getter and setter 
       private String res; // getter and setter 
       ... 
    
       public void someThingToDoListener(AjaxBehaviorEvent event) { 
           //res = some processing
        }
    
    }
    

    See Also

    • JSF2: Ajax in JSF – using f:ajax tag

提交回复
热议问题