【发布时间】:2014-06-25 14:34:34
【问题描述】:
大家早上好,我有一个关于 JSF 导航和用于导航的问题。在我将三个 .xhtml 文件放入子文件夹之前,我的导航工作正常。我在同一个文件夹中有 Home.xhtml、A.xhtml、B.xhtml 和 C.xhtml。将 A、B 和 C.xhtml 放入子文件夹 A、B 和 C,然后从 Home.xhtml 导航到 A.xhtml,然后到 B.xhtml,我收到此错误:“/A/B/B .xhtml 未在 ExternalContext 中作为资源找到”。显然页面在 URL 中堆积,但我不确定为什么。
我的豆子:
@ManagedBean(name="company")
@SessionScoped
public class CompanyBean implements Serializable {
private static Map<String, Object> companyValue;
public String value;
boolean temp;
public static Map<String, Object> getCompanyValues() {
return companyValue;
}
public boolean getTemp() {
if (Env.isProd()==true)
{
return true;
}
return false;
}
public void setTemp()
{
temp=Env.isProd();
}
public static void setCompanyValues(Map<String, Object> companyValues) {
CompanyBean.companyValue = companyValues;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public CompanyBean()
{
companyValue=new LinkedHashMap<String, Object>();
companyValue.put("Select Company", "choose");
companyValue.put("AE", "AE/AE.xhtml");
companyValue.put("BP", "BP/BP.xhtml");
companyValue.put("CBK", "CBK/CBK.xhtml");
}
public Map<String,Object> getCompanyValue() {
return companyValue;
}
public void navigate(ValueChangeEvent event)
{
String page= event.getNewValue().toString();
try {
FacesContext.getCurrentInstance().getExternalContext().redirect(page);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
我的jsf代码:
<h:form>
<h:selectOneMenu value="#{company.value}" valueChangeListener="#{company.navigate}" onchange="this.form.submit()">
<f:selectItems value="#{company.companyValue}" />
</h:selectOneMenu>
</h:form>
对不起,如果这个问题已经回答了,因为现在是早上,我半醒着。
【问题讨论】:
-
可能是因为您正在重定向到相对 URL。
-
你在 faces-config.xml 中使用导航箱吗?
-
@JosefE。我没有尝试创建表格,也没有尝试使用 ajax 和 javascript。我的导航有效,但当文件位于子目录中时无效。
标签: java jsf navigation xhtml