jsf中的新标签
New tab in a jsf
我想知道在这种情况下是否有打开新标签的方法:
我在一个页面中有一个 table 客户 (searchCustomer.jsf)
在每一行我都有一个命令 link 来编辑这个特定的客户。
命令link的代码是这个:
<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>
在托管 bean 中我有 setCustomer 函数:
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";
}
我已经在我的脸上设置了页面-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>
如果我只单击 link,该函数就会执行我想要的操作。 (页面转到manageCustomer.jsf);
但如果我尝试在新选项卡中打开 link(右键单击 -> 在新选项卡中打开)(页面返回到我的 searchCustomer.jsf)
有没有办法使最后一个选项(在新选项卡中打开)与第一个选项(单击 link)相同?
如果您需要更多信息,请告诉我
没有。至少在不重构代码的情况下。
当您从浏览器 select new tab
context-menu 时,浏览器所做的只是:
- 复制target-url
- 在新标签页中打开它。
并且由于 (html-technically) 您的 link 将指向 /pages/searchCustomer.jsf
- 您最终将再次出现在第一页上。
处理此问题的唯一方法是为您的应用程序设计 deep-links。也就是说,您的 "manage" 按钮应该指向 URL /pages/manageCustomer.jsf?customer_id=5988
,您可以在其中使用 <f:viewParam name="customer_id" value="#{bean.selectedCustomerId} />
将 url-parameter customer_id
放回 bean-property做进一步的处理。
但是使用它会扼杀在 jsf-webapps 上使用 partial-responses 的意义,因为它会以 request/response-model 结束以获取 GET-Parameters。
如果用于内部目的,请教你的人 web-app 不是 web-site,因此适用不同的规则:-)
我的意思是:您也不能只在 new-tab 中打开任何 POST-Form (vanilla-html) 的 "submit-button"。它也不会工作。每个人都有这个,所以这只是一个习惯问题。将您的 link 更改为 "Buttons",没有人会期望能够在新标签页中打开它。
我想知道在这种情况下是否有打开新标签的方法:
我在一个页面中有一个 table 客户 (searchCustomer.jsf)
在每一行我都有一个命令 link 来编辑这个特定的客户。
命令link的代码是这个:
<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>
在托管 bean 中我有 setCustomer 函数:
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";
}
我已经在我的脸上设置了页面-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>
如果我只单击 link,该函数就会执行我想要的操作。 (页面转到manageCustomer.jsf);
但如果我尝试在新选项卡中打开 link(右键单击 -> 在新选项卡中打开)(页面返回到我的 searchCustomer.jsf)
有没有办法使最后一个选项(在新选项卡中打开)与第一个选项(单击 link)相同?
如果您需要更多信息,请告诉我
没有。至少在不重构代码的情况下。
当您从浏览器 select new tab
context-menu 时,浏览器所做的只是:
- 复制target-url
- 在新标签页中打开它。
并且由于 (html-technically) 您的 link 将指向 /pages/searchCustomer.jsf
- 您最终将再次出现在第一页上。
处理此问题的唯一方法是为您的应用程序设计 deep-links。也就是说,您的 "manage" 按钮应该指向 URL /pages/manageCustomer.jsf?customer_id=5988
,您可以在其中使用 <f:viewParam name="customer_id" value="#{bean.selectedCustomerId} />
将 url-parameter customer_id
放回 bean-property做进一步的处理。
但是使用它会扼杀在 jsf-webapps 上使用 partial-responses 的意义,因为它会以 request/response-model 结束以获取 GET-Parameters。
如果用于内部目的,请教你的人 web-app 不是 web-site,因此适用不同的规则:-)
我的意思是:您也不能只在 new-tab 中打开任何 POST-Form (vanilla-html) 的 "submit-button"。它也不会工作。每个人都有这个,所以这只是一个习惯问题。将您的 link 更改为 "Buttons",没有人会期望能够在新标签页中打开它。