Jsf Primefaces复制DOM中的元素

Jsf Primefaces复制DOM中的元素,jsf,primefaces,Jsf,Primefaces,每次我点击一个按钮或进入一个对话框,我的overlypanel都会在DOM中复制,例如,不可能将一个简单字段发送到后端。我花了很多时间试图看看它是否与p:commandbutton进程/更新相关,或者甚至是与控制器相关的某个错误的生命周期,或者甚至是观看关于这里的讨论 下面是我的三个重叠面板,这是我观点的一部分 注意:我试图在覆盖面板中使用dynamic=true,错误消失了,但是我的css完全崩溃了 注意²:我一直在做其他测试,发现在某些机器上该代码有效,而在其他机器上则无效。我尝试切换浏览器

每次我点击一个按钮或进入一个对话框,我的
overlypanel
都会在DOM中复制,例如,不可能将一个简单字段发送到后端。我花了很多时间试图看看它是否与
p:commandbutton
进程/更新相关,或者甚至是与控制器相关的某个错误的生命周期,或者甚至是观看关于这里的讨论

下面是我的三个重叠面板,这是我观点的一部分 注意:我试图在
覆盖面板
中使用
dynamic=true
,错误消失了,但是我的css完全崩溃了

注意²:我一直在做其他测试,发现在某些机器上该代码有效,而在其他机器上则无效。我尝试切换浏览器并发出相同的请求,但什么也没有。我真的不知道还能做什么

我正在使用Java8和PrimeFaces7


    • 我看不出我在表单中使用它,请将元素放在表单中。 字母“h”是因为它是一个jsf元素

      <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:p="http://primefaces.org/ui">
          ...
      
          <h:form id="idForm">
          
           ...
          
          </h:form>
      
      
      ...
      ...
      
      还要注意这一点:

      版本更改6.2->7.0

      覆盖面板:附件主体已移除。使用appendTo=“@(正文)” 相反


      您可以查看更多信息

      查看更新
      formDialog
      appendToBody=“true”
      ,我认为这是您问题的关键。我试图查看此属性appendToBody to,但是如果没有成功,formDialog是一个表单,当点击面板中的任何按钮并发出请求时,所有内容都将被更新。但是,我也试着用你的方式来做,但是没有成功。用一个或几个项目来测试,以排除可能的错误。这里你可以看到一个使用覆盖面板的例子:我明白了,我从周五开始就在做这个sprint活动,所以我最后尝试了几件事,包括这件事来隔离错误,并且只使用覆盖。例如,我看到,当我不仅单击按钮,而且打开对话框本身时,也会发生同样的行为。每次我这样做,都会创建+三个覆盖面板,而不是重复使用,就好像组件处理是错误的,我不确定,但我会继续在我的机器上进行测试。请注意,我在回答中添加的关于从版本6.2到版本7关于AppendToBody的更改的最后一件事,我得到了!这个属性的错误现在已经消失了,muito obrigado amigo!
      package eprecise.sgv.server.fiscal.nfes;
      
      import java.io.IOException;
      import java.io.Serializable;
      import java.util.Optional;
      
      import javax.ejb.ConcurrentAccessTimeoutException;
      import javax.enterprise.context.RequestScoped;
      import javax.inject.Inject;
      import javax.inject.Named;
      import javax.net.ssl.SSLHandshakeException;
      import javax.validation.constraints.NotNull;
      import javax.validation.constraints.Size;
      
      import eprecise.sgv.server.core.infra.CacheOnRenderResponse;
      import eprecise.sgv.server.core.util.FacesMessageUtil;
      import eprecise.sgv.server.core.validation.HandleConstraintViolations;
      import eprecise.sgv.server.fiscal.nfes.events.NFeCancelSyncUnauthorized;
      import eprecise.sgv.server.fiscal.nfes.events.NFeCancellationEvent;
      import eprecise.sgv.server.fiscal.nfes.transmission.NFeTransmissionChannel;
      
      
      @Named
      @RequestScoped
      @HandleConstraintViolations
      @CacheOnRenderResponse
      public class NfesCancellationController implements Serializable {
      
          private static final long serialVersionUID = 1L;
      
          private @NotNull @Size(min = 15, max = 255) String justification;
      
          private final NfesController controller;
      
          private final NFeTransmissionChannel transmissionChannel;
      
          private final NFesRepository repository;
      
          public NfesCancellationController() {
              this.controller = null;
              this.transmissionChannel = null;
              this.repository = null;
          }
      
          @Inject
          public NfesCancellationController(final NfesController controller, final NFeTransmissionChannel transmissionChannel, final NFesRepository repository) {
              this.controller = controller;
              this.transmissionChannel = transmissionChannel;
              this.repository = repository;
          }
      
          public String getJustification() {
              return this.justification;
          }
      
          public void setJustification(final String justification) {
              this.justification = justification;
          }
      
          public void doCancellation() {
              this.controller.setEntity(this.repository.find(this.controller.getEntity()));
              if (this.isBtnCancelEnabled()) {
                  try {
                      this.controller.getEntity().cancel(this.transmissionChannel, this.justification);
                      this.controller.getEntity().getLastEvent().ifPresent(e -> {
                          if (e instanceof NFeCancellationEvent) {
                              FacesMessageUtil.addInfoMessage("Cancelada com sucesso");
                          } else if (e instanceof NFeCancelSyncUnauthorized) {
                              final NFeCancelSyncUnauthorized unauthorized = (NFeCancelSyncUnauthorized) e;
                              FacesMessageUtil.addWarnMessage(String.format("Não cancelada por: %s", unauthorized.getDetails()));
                          } else {
                              FacesMessageUtil.addInfoMessage("Transmissão efetuada, veja mais detalhes no histórico");
                          }
                      });
                      this.repository.update(this.controller.getEntity());
                  } catch (final ConcurrentAccessTimeoutException e) {
                      FacesMessageUtil.addWarnMessage("Não foi possível transmitir, tente novamente em alguns instantes");
                  } catch (final RuntimeException e) {
                      if ((e.getCause() instanceof SSLHandshakeException) || (e.getCause() instanceof IOException)) {
                          FacesMessageUtil.addWarnMessage("Houve um erro de comunicação com a sefaz. Tente novamente em alguns instantes");
                      } else {
                          throw e;
                      }
                  }
              } else {
                  FacesMessageUtil.addErrorMessage("Não é possível cancelar a NFe");
              }
          }
      
          public boolean isBtnCancelEnabled() {
              return this.controller.isInViewMode() && Optional.ofNullable(this.controller.getEntity()).map(BaseNFe::isAllowedToCancel).orElse(false);
          }
      }
      
      <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:p="http://primefaces.org/ui">
          ...
      
          <h:form id="idForm">
          
           ...
          
          </h:form>