I have an inputText and a commandButton in a JSF page. The user inputs something and then gets redirected in a result page which also has has an inputText and commandButton with the same functionality. The commandButton should perform some action when clicked and redirect to a REST url (result page) which is constructed by appending the inputText value into a base URL. I tried many things but I did not manage to make this work in the second page. What I tried until now is:
-
Inside the action of the commandButton I call my methods and then return the URL for the redirection since I have the inputText value in my bean. I used AJAX to render the commandButton on a keyup event. This works for page 1 but not for page 2. The problem is that each time a user types a letter, the button is rendered and my methods are called which I do not want as I only want to call them when the user clicks the button.
-
I created a method in my bean in which I put all my methods. I tried both making the method PostConstruct and having an f:event with preRenderView for calling the method. Again with AJAX this does not work since the method is called each time a user types something.
Just don’t render the button then. Perhaps you’ve used a too general client identifier in
<f:ajax render>attribute like as@form. Just replace it something more specific which excludes the button.Just check if it isn’t an ajax request.