小编Kuk*_*tje的帖子

输入多个带标签而不自动完成

我有两个输入。

我希望两个输入具有相同的外观和感觉,见下文:

在此处输入图片说明

第一个输入使用自动完成并允许用户选择术语列表 => 我使用p:autocomplete(请参阅关于自动完成的 Primefaces 文档)此输入工作正常。

对于第二个输入,我希望有相同的显示,但没有任何自动完成功能:用户只需输入一个根本没有自动完成功能的术语列表。我试图有一个假的自动完成,它返回用户给定的值,但它太慢了,而且当用户退出输入时行为不正确。

欢迎任何想法。

tags jsf autocomplete input primefaces

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

带有primeng的Angular2复选框失败

我正在使用 angular2 cli,这是我设置表单的方式

在组件中

export class UsersAddComponent implements OnInit {

 ngOnInit() {
    this.userForm = this._formBuilder.group({
      role: ['', [Validators.required]],
      others: this._formBuilder.array([])  //for adding multipe form inputs
    });

   this.addNewUser();

  }

  initAddress() {
     return this._formBuilder.group({     
       sendcred: [''],  //checkbox needs no validation in my logic
        needs_reset: [''], // ''
        .....other fields here
    });
 }


  addNewUser() {  //this is called whenever add new user button is clicked
     const control = <FormArray>this.userForm.controls['others'];
     const addrCtrl = this.initAddress();
     control.push(addrCtrl);
   }
Run Code Online (Sandbox Code Playgroud)

在 html 模板中,我使用了这样的 Primeng 复选框

  <p-checkbox formControlName="needs_reset" label="User …
Run Code Online (Sandbox Code Playgroud)

checkbox typescript angular

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

从p:dataTable创建复合组件时,"组件不支持事件"错误

从primefaces dataTable创建复合组件时出现以下错误.我究竟做错了什么 !?

Exception 

    javax.faces.view.facelets.TagException: /view/restrito/basico/municipio.xhtml @77,165 <p:ajax> Composite component does not support event rowSelect
Run Code Online (Sandbox Code Playgroud)

tabela-padrao.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:cc="http://xmlns.jcp.org/jsf/composite"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:p="http://primefaces.org/ui"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:h="http://xmlns.jcp.org/jsf/html">

<!-- INTERFACE -->
<cc:interface>
    <cc:attribute name="uniqueId" required="true" />
    <cc:attribute name="value" required="true" />
    <cc:attribute name="var" required="true" />
    <cc:attribute name="selection" required="true" />
    <cc:attribute name="exportedFileName" required="true" />
    <cc:attribute name="renderedTable" default="true"/>
    <cc:attribute name="primaryKey" required="true"/>

</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>
    <p:dataTable value="#{cc.attrs.value}" 
                 id="#{cc.attrs.uniqueId}"
                 scrollable="true"
                 scrollWidth="100%"
                 var="#{cc.attrs.var}"
                 rendered="#{cc.attrs.renderedTable}"
                 selection="#{cc.attrs.selection}"
                 rowKey="#{cc.attrs.primaryKey}"                                             
                 selectionMode="single"
                 paginator="true"
                 rowsPerPageTemplate="15,30,45"
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}"
                 emptyMessage="#{bundle.tabela_nenhum_registro_encontrado}">
        <cc:insertChildren/> …
Run Code Online (Sandbox Code Playgroud)

datatable primefaces jsf-2

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

无法对齐数据表小平面页脚中的按钮

使用Primefaces 6.1,我想在数据表页脚面上添加几个按钮.当我使用float:left时,按钮向左移动但是页脚部分(div)收缩.

<f:facet name="footer">
    <p:button styleClass="tableButtons" value="Edit" update="msgs"/>
</f:facet>  
Run Code Online (Sandbox Code Playgroud)

默认输出为:

在此输入图像描述

现在,如果我添加浮动:

    .tableButtons {
         float: left;
    }
Run Code Online (Sandbox Code Playgroud)

输出是:

在此输入图像描述

css primefaces

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

如何在 ap:tooltip 中的 p:messages 中添加换行符

我试图在密码归档应具有的规则列表之间添加换行符:

希望这段代码可以帮助您在本地计算机上重现它

我的 JSF 表单如下所示:

<h:form id="passwordForm">
     <div class="form-group has-feedback">
        <p:password id="password1" value="#{testBean.password}"
                    required="true"
                    requiredMessage="This field cannot be left empty"
                    placeholder="Password">
        </p:password>
        <p:tooltip for="password1"  id="password1ToolTip"
                   hideEvent="focus"
                   rendered="#{not empty facesContext.getMessageList('passwordForm:password1')}"
                   position="right" hideEffect="fade" showEffect="fade">
            <p:message for="password1"/>
        </p:tooltip>
    </div>
</h:form>
Run Code Online (Sandbox Code Playgroud)

这就是我的豆子的样子:

@Named
@RequestScoped
public class TestBean implements Serializable {

    private static final long serialVersionUID = 2016821444602021904L;


    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}", 
    message = "Password should contain minimum 8 characters, 1 Uppercase alphabet, 1 lower case alphabet and 1 special character")
    @Size(min = 8, message = …
Run Code Online (Sandbox Code Playgroud)

jsf styles tooltip primefaces

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

为什么会收到WELD-001303:作用域类型javax.enterprise.context.RequestScoped异常没有活动上下文?

我已经在网站上查看了与该错误有关的其他问题,但其中大多数都是关于SessionScope的,或者没有答案。唯一可能有用的是从线程中调用bean时,作用域类型javax.enterprise.context.RequestScoped没有活动上下文,但它不在我所拥有的上下文中。

我在Wildfly 10.1(Java ee 7)上运行JAX-RS端点。看起来像这样:

@Path("")
public class ServerResource {

    @Inject
    Order order;

    @Resource
    ManagedExecutorService mes;

    @PUT
    @Path("/prepareOrder")
    public void prepareOrder(@Suspended AsyncResponse response) {
        mes.execute(() ->  {
            try {
                Item item = new Item(); // JPA entity
                order.setItem(item); // line 71
                // call a service to save the order data (like item) to the DB
            } catch (Exception e) {
                e.printStackTrace();
                response.resume(false);
            }
            response.resume(true);
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

我添加try-catch仅仅是因为这个问题,它通常不存在。 Order

@Stateful
@RequestScoped
public class Order {
    private Item …
Run Code Online (Sandbox Code Playgroud)

jax-rs cdi wildfly

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

h:dataTable始终显示一行;将不显示零行

我正在使用旧版JSF Web应用程序,而我的h:dataTable元素给我带来了麻烦。通常,它显示的正是我想要的方式-标头和几行,所有行都带有适当的填充和边距。

h:数据表正确显示三行

但是,如果我尝试显示具有零行的表(这对我来说是一个有效的用例),那么JSF仍将呈现一行,尽管没有内容。

h:dataTable应该渲染零行时渲染一空行

这是此h:dataTable的源代码:

<h:dataTable styleClass="table" value="#{backingBean.emptyList}" var="result">

    <h:column>
        <f:facet name="header">First Column</f:facet>
        <h:outputText value="#{result}"/>
    </h:column>

    <h:column>
        <f:facet name="header">Second Column</f:facet>
        <h:outputText value="#{result}"/>
    </h:column>

    <h:column>
        <f:facet name="header">Third Column</f:facet>
        <h:outputText value="#{result}"/>
    </h:column>

</h:dataTable>

Run Code Online (Sandbox Code Playgroud)

这是浏览器呈现的内容:

<table class="table">
    <thead>
        <tr>
            <th scope="col">First Column</th>
            <th scope="col">Second Column</th>
            <th scope="col">Third Column</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

以下是支持bean的方法,这些方法可以为我提供结果列表:

public List<String> getEmptyList() { // incorrectly renders 1 empty row
    return Collections.emptyList();
}

public List<String> getThreeRows() { // correctly renders 3 rows
    return Arrays.asList(new String[] …
Run Code Online (Sandbox Code Playgroud)

css jsf jsf-2

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

单击行展开 prime-ng 的 p 表行

此处的链接https://www.primefaces.org/primeng/#/table/rowexpansionp-table显示了可以通过单击使用指令的第一列来展开行的示例pRowToggler

我试图通过单击行上任意位置的行来实现这种切换。

我曾尝试寻找这样的例子,但找不到。[pRowToggler]我也尝试过在该行上使用ng-template,但这也不起作用。

有人可以指导我如何实现这种行为吗?

primeng angular primeng-datatable

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

Wildfly 启动时出现错误。javax.faces.FacesException:无法找到 CDI BeanManager

我已经使用 WildFly 18(jdk-13.0.1)在 eclipse 中编写了我的第一个 JSF hello world 程序。,Windows 10。

Wildfly 主页和管理控制台工作正常,但从 url 执行程序时http://localhost:8080/jsf1/faces/WEB-INF/helloworld.xhtml出现404 - Not Found错误。我在 url 上遇到同样的错误http://localhost:8080/jsf1

这是 web.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>jsf1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

下面是 Wildfly 服务器日志

2020-01-06 10:59:19,677 INFO  [org.jboss.as.patching] (MSC service thread 1-2) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: …
Run Code Online (Sandbox Code Playgroud)

jsf jboss wildfly

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

pe:documentViewer 不显示 PDF 中的数字签名

我有一个多格式文档查看器,在其中,为了显示 PDF,我使用 PF Extension 的p:documentViewer组件。提供 PDF StreamedContent 的支持 bean 已进行阶段渲染并按预期工作。然而,尽管 PDF 本身渲染得很好,但查看者不会显示其中的数字签名p:documentViewer使用时需要添加额外的配置吗?这是我的用法:

<pe:documentViewer id="pdfVw" height="600" width="800" value="#{viewerController4.pdfDocumentStream}">                                           
    <f:param name="id" value="#{viewerController4.currentDocId}" /> 
</pe:documentViewer> 
Run Code Online (Sandbox Code Playgroud)

提供 PDF 内容的支持 bean 方法:

public StreamedContent getPdfDocumentStream() throws IOException {
        FacesContext context = FacesContext.getCurrentInstance();

        if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
            return new DefaultStreamedContent();
        } else {
            String id = context.getExternalContext().getRequestParameterMap().get("id");
            Doc doc = pdfDocMap.get(id);

            return new DefaultStreamedContent(new FileInputStream(new File(doc.getDocPath())), "application/pdf", doc.getDocName());

        }
    }
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我在 UI 上还有一个功能,用于显示文档的缩略图 - 对于 PDF,我使用 PDFBox 提取第一页并将其转换为 PNG …

pdf primefaces primefaces-extensions pdf.js

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