小编hen*_*eng的帖子

p:commandLink无法在新窗口/选项卡中打开页面

我正在尝试创建一个链接,在不同的窗口/选项卡中打开一个新页面,并显示一些来自支持bean的消息但是没有这样做,想知道为什么?

这是我的xhtml文件:

<html:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:ui="http://java.sun.com/jsf/facelets">
  <h:body>
    <h:form id="form66">
    <p:commandLink actionListener="#{testing.getMessage}" action="msg.xhtml" target="_blank">get Msg</p:commandLink>
    </h:form>
  </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我的Msg.xhtml页面

<HTML xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:ui="http://java.sun.com/jsf/facelets">
  <h:head>
    <title>testing</title>
  </h:head>
  <h:body>
    <div class="div">
      <p:panel>
        <f:facet name="header">
          testing
        </f:facet>
        <div class="paddingForPanel">
          <h:outputText value="#{testing.msg}" escape="false"/>             
        </div>
      </p:panel>            
    </div>
  </h:body>
</HTML>
Run Code Online (Sandbox Code Playgroud)

这是我的testing.java

public void getMessage() {      
    this.msg = "haha";
}

private String msg;
public String getMsg() {
    return msg;
}
public void setMsg(String msg) {
    this.msg = msg;
}
Run Code Online (Sandbox Code Playgroud)


上面的代码无法打开一个新的选项卡/窗口,我尝试像下面这样做,它成功在新选项卡中打开新页面但msg为空,当我调试时,它成功调用了监听器getMessage,我想知道为什么msg.xhtml页面中的msg为空?提前致谢....

<p:commandLink actionListener="#{testing.getMessage}" oncomplete="window.open('msg.xhtml')">broadcast …
Run Code Online (Sandbox Code Playgroud)

jsf commandlink primefaces jsf-2

20
推荐指数
3
解决办法
8万
查看次数

用户登录后如何重定向回用户所需的访问页面?

在用户登录之前,如果键入xxx.detail.jsf,它将重定向到登录页面,让用户登录.这项任务已经完成.如何xxx.detail.jsf在用户成功登录后将其重定向回到?

我正在使用Eclipse Indigo,Tomcat 7和Mojarra 2.0.3.

redirect login jsf-2

7
推荐指数
1
解决办法
4542
查看次数

primefaces菜单无法在全页面布局中完全显示

几天前我在primefaces论坛上问了一个问题,但没有人回复我.

我在使用全页布局(position ="west")时遇到问题,子菜单无法完全显示出来.可以使它显示重叠(位置="中心"),因为我不希望增加西部布局的宽度?

下面链接atatch与图片作为参考.

http://www.imagebucket.net/bucket/is.php?i=10434&img=image.jpg

这是代码的一部分:

<p:layoutUnit position="west" size="200" >  
  <ui:insert name="sideBar">                        
    <h:form>
      <p:menu type="tiered" >  
        <p:submenu label="Sales" >                                      
          <p:menuitem disabled="#{user.customer}" value="Approve" url="/sales/approve.jsf" style="width:50px" />                                                
        </p:submenu> 
        <p:separator />  
        <p:submenu label="Customer">   
          <p:menuitem disabled="#{user.sales}" value="customer" url="/customer/customer.jsf" style="width:50px" />
        </p:submenu>
      </p:menu>
    </h:form>          
  </ui:insert>  
</p:layoutUnit>
Run Code Online (Sandbox Code Playgroud)

我只是将primefaces更新为3.1,并发现有1个功能overlayPanel,我可以知道它是否可以用于解决我的问题?

提前致谢..

[Eclipse Indigo,tomcat 7,Java EE 6,PrimeFaces 3.1,Mojarra 2.0.3]

layout menu overlap primefaces

5
推荐指数
1
解决办法
9311
查看次数

如何在自定义多字段验证器中标记其他组件无效

我指的是BalusC的答案之一: JSF不支持跨领域验证,是否有解决方法?

我按照相同的方式,并提出如下代码:

在.xhtml中

<h:form id="form1">
  <div>
    <p:messages globalOnly="true" display="text" />

        <h:inputHidden value="true">
            <f:validator validatorId="fooValidator" />
            <f:attribute name="input1" value="#{input1}" />
            <f:attribute name="input2" value="#{input2}" />
            <f:attribute name="input3" value="#{input3}" />
        </h:inputHidden>

        <h:panelGrid columns="3">  
            <h:outputText value="name 1: " />
            <p:inputText binding="#{input1}" id="input11" value="#{testPage.input1}" />
            <p:message for="input11" display="text"/>
        </h:panelGrid>
        <h:panelGrid columns="3">
            <h:outputText value="name 2: " />               
            <p:inputText binding="#{input2}" id="input22" value="#{testPage.input2}" />
            <p:message for="input22" display="text"/>
        </h:panelGrid>
        <h:panelGrid columns="3">
            <h:outputText value="name 3: " />
            <p:inputText binding="#{input3}" id="input33" value="#{testPage.input3}" />
            <p:message for="input33" display="text"/>
        </h:panelGrid>
        <p:commandButton value="Submit" action="#{testPage.submitValidator}" …
Run Code Online (Sandbox Code Playgroud)

validation jsf primefaces jsf-2

5
推荐指数
1
解决办法
1万
查看次数

有一些未处理的FacesMessages,这意味着并非每个FacesMessage都有机会被渲染

我有一个JSF 2.1 + PrimeFaces 3.3页面:

<h:form id="particluar">
  <p:message id="msg" globalOnly="true" display="text"/>

  <h:panelGrid columns="2" id="test">
    <h:panelGrid id="panel2" columns="3">
      <p:inputText id="name1" value="Student.studentID" required="true"/>          
      <p:commandButton value="Check Name" actionListener="#{Student.abc}" process="name1" update="panel2" />
      <p:message id="msg1" for="name1" display="text"/>
    </h:panelGrid>

    <p:inputText id="name2" required="true"/>
    <p:message id="msg2" for="name2" display="text"/>

    <p:inputText id="name3" required="true"/>
    <p:message id="msg3" for="name3" display="text"/>

  </h:panelGrid>
  <p:commandButton value="submit" actionListener="#{Student.xyz}" update="particluar" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

我试图在名称无效时手动添加面孔消息:

public void xyz() {
  if (name1.equals("primefaces")) {
    FacesContext.getCurrentInstance().addMessage("msg1", new FacesMessage(FacesMessage.SEVERITY_ERROR,"Invalid Name", "Invalid Name"));
  }
  if (name2.equals("primefaces")) {
    FacesContext.getCurrentInstance().addMessage("msg2", new FacesMessage(FacesMessage.SEVERITY_ERROR,"Invalid Name", "Invalid Name"));
  }
  if …
Run Code Online (Sandbox Code Playgroud)

jsf message

2
推荐指数
1
解决办法
9868
查看次数

标签 统计

jsf ×3

jsf-2 ×3

primefaces ×3

commandlink ×1

layout ×1

login ×1

menu ×1

message ×1

overlap ×1

redirect ×1

validation ×1