Note that there are some explanatory texts on larger screens.

plurals
  1. POh:commandbutton invoking bean method only once that redirects to a different page in new tab
    primarykey
    data
    text
    <p>I am using jsf h:commandButton . My Requirement is that based on value of Button , i have to handle the action . I have used following </p> <pre><code>&lt;h:commandButton id="raisecm" render="@all " styleClass="btn btn-primary" execute="@this" value="#{scenarioConfigurationMB.status}" actionListener="#{scenarioConfigurationMB.createPatchingCMTicket()}" onclick="if(this.value=='Edit Ticket'){this.form.target='_blank';}"&gt; &lt;/h:commandButton&gt; </code></pre> <p>Here status can be either "Create Ticket" or "Edit Ticket". If status is "Create Ticket" i have to create a ticket in Backing Bean method "createPatchingCMTicket" , otherwise if the status is "Edit Ticket" i have to return open a page in new tab showing its details.</p> <p>Method in backing bean is as:</p> <pre><code> public String createPatchingCMTicket() { System.out.println("***********************Ticket ID"+ ticketId); ticketId="123"; System.out.println("Checking Status of CM Ticket For Patching ......"); if (status.equals("Edit Ticket")) { System.out.println("*********Status is \"Edit Ticket\""); try{ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); externalContext.redirect("/cm/view_ticket.xhtml?changeTicketId="+ticketId); } catch(Exception e){ System.out.println("Redirection Failed........`enter code here`..................***************"); throw new FacesException("Redirection failed......"); } System.out.println("********Redirected........"); return null; } System.out.println("Creating Ticket.............***********"); log.info("Creating CM Ticket For Patching ......"); //Code for Creating Ticket </code></pre> <p>}</p> <p>If I am using above concept in h:commandButton , if the status is "Edit Ticket" , it is working fine and redirecting to the other url in new tab but only for first click and if I again click on 'Edit Ticket' it is opening the same base page in new tab and not redirecting to new page. </p> <p>I have struggled a lot to resolve this unexpected issue. Kindly help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload