I want to know if there is a way to open a new tab in this situation:
I have a table in a page with customers (searchCustomer.jsf)
On each row I have a command link to edit this particular customer.
The code for the command link is this one:
<p:column styleClass="buttonColumn" exportable="false" >
<p:commandLink title="#{msg.set}"
action="#{searchCustomerManageBean.setCustomer(customer)}"
disabled="#{ not searchCustomerManageBean.canEdit(customer)}"
value="#{msg.edit}"/>
</p:column>
in the managed bean I have the setCustomer function:
public String setCustomer(Customer customer) {
setcustomerSelected(customer);
final DataTable d1 = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:basicDT");
int first1 = d1.getFirst();
actualPage = first1;
WebUtils.putObjectOnFlashContext("customerId", customer.getCustomerId());
WebUtils.putObjectOnFlashContext("Back page", "GO_TO_CUSTOMER_SEARCH");
WebUtils.putObjectOnFlashContext("read only", Boolean.FALSE);
return "GO_TO_CUSTOMER";
}
I have set up the pages in my faces-config.xml
faces-config.xml
<navigation-case>
<from-outcome>GO_TO_CUSTOMER_SEARCH</from-outcome>
<to-view-id>/pages/searchCustomer.jsf</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>GO_TO_CUSTOMER</from-outcome>
<to-view-id>/pages/manageCustomer.jsf</to-view-id>
<redirect/>
</navigation-case>
If I just click on the link, the function does what I want. (The page go to manageCustomer.jsf);
but if I try to open the link in a new tab(rigth click ->open in an new tab) (the page go back to my searchCustomer.jsf)
Is there a way to make this last option(open in a new tab) works same as the first option(click the link)?
please let me know if you need more information
No. At least not without refactoring your code.
When you select new tab
from the browsers context-menu, all the browser does is:
and since (html-technically) your link would point to /pages/searchCustomer.jsf
- you'll end up on the first page again.
The only way to handle this is designing deep-links for your application. i.e. your "manage" button should refer to the URL /pages/manageCustomer.jsf?customer_id=5988
, where you use <f:viewParam name="customer_id" value="#{bean.selectedCustomerId} />
to put the url-parameter customer_id
back into a bean-property to do further processing.
But using this will kill the point of using partial-responses on jsf-webapps, as it would end up with a request/response-model in order to fetch the GET-Parameters.
If used for internal purpose, teach your people, that a web-app is not a web-site, so different rules apply :-)
I mean: You also can't just open a "submit-button" of any POST-Form (vanilla-html) in a new-tab. It also won't work. Everybody got this, so it's just a question of habit. Change your links to "Buttons" and no one would ever expect to be able to open it in a new tab.