JSF2的Inputtext小部件将不允许用户在XHTML UI中输入数据

如何解决JSF2的Inputtext小部件将不允许用户在XHTML UI中输入数据

我正在将JSF1.1应用程序转换为JSF2。但是,我发现从初始视图导航到新视图时,inputText小部件将不允许从屏幕输入任何数据。使用锚标记或通过在浏览器中输入URL调用的初始视图不会发生此问题。我正在使用Wildfly 19.1 Primefaces 7.0和JSF 2.3。我该如何调试呢?

这是我的pom.xml文件。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.llts</groupId>
    <artifactId>LingoMavenApps</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>LingoMavenApps</name>

    <repositories>
        <repository>
            <id>myMavenRepoLltsRead</id>
            <url>https://mymavenrepo.com/repo/604lAqKzBoKcfngw9N2d/</url>
        </repository>
        <repository>
            <url>http://repository.primefaces.org/</url>
            <id>PrimeFaces-maven-lib</id>
            <layout>default</layout>
            <name>Repository for library PrimeFaces-maven-lib</name>
        </repository>
        <repository>
            <id>JBoss repository</id>
            <url>http://repository.jboss.org/nexus/content/groups/public/</url>
        </repository>
    </repositories>

    <distributionManagement>
        <repository>
            <id>myMavenRepoLltsWrite</id>
            <url>https://mymavenrepo.com/repo/ETqr5l5RKE7x67iZUvi9/</url>
        </repository>
    </distributionManagement>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jsf.version>2.3.2</jsf.version>
        <javase.version>1.8</javase.version>
        <javaee-endorsed.version>7.0</javaee-endorsed.version>
        <javaee.version>8.0</javaee.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    <dependencies>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.20</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>18.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.0</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>7.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.faces</artifactId>
            <version>${jsf.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>${javaee.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.llts</groupId>
            <artifactId>burnsiderest</artifactId>
            <version>1.7.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${javase.version}</source>
                    <target>${javase.version}</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>${javaee-endorsed.version}</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
               <artifactId>maven-resources-plugin</artifactId>
               <version>2.6</version>
               <executions>
                  <execution>
                     <id>copy-resources</id>
                     <phase>validate</phase>
                     <goals>
                        <goal>copy-resources</goal>
                     </goals>
                     <configuration>
                        <outputDirectory>${basedir}/target/LingoMavenApps/resources
                           </outputDirectory>
                        <resources>          
                           <resource>
                              <directory>src/main/resources</directory>
                              <filtering>true</filtering>
                           </resource>
                        </resources>              
                     </configuration>            
                  </execution>
               </executions>
            </plugin>            
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>
</project>

这是UI视图之一client.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!-- 
    Document   : client
    Created on : Mar 9,2020,5:49:08 PM
    Author     : mphoenix
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <h:outputStylesheet name="css/burnsideweb.css" />
        <title>JSF Page</title>
    </h:head>
    <h:body>
        <f:view>
            <p:messages showDetail="true" showSummary="true" id="msgs">
                <p:autoUpdate />
            </p:messages>
            <h:panelGrid columns="3" styleClass="tableComp" >
                <h:outputText value="Client Creator" styleClass="title"/>
                <h:outputText style="width: 30px" />
                <h:form enctype="multipart/form-data"  prependId="false">
                    <h:panelGroup styleClass="ccXmlUploader">
                        <h:outputText value="Load XML File" style="font-size: 10pt;"/>
                        <br/>
                        <p:fileUpload update="process" auto="true" style="width:500px;"
                                fileUploadListener="#{clientCreator.handleUpload}" allowTypes="/(\.|\/)(xml)$/" />
                        <br/>
                        <h:commandButton value="Apply" type="submit" action="#{clientCreator.processClientFile}"
                                         disabled="#{clientCreator.processDisabled}"
                                         id="process" />
                    </h:panelGroup>
                </h:form>
            </h:panelGrid>
            <p/>
            <p:dialog
                widgetVar="statusDialog"
                modal="true"
                draggable="false"
                resizable="false"
                showHeader="false"
                position="center top+150"
                closable="false"
                style="padding: 20px;">  
                <h:outputText value="Processing... patience please."
                                   style="padding-right:15px;" />
                <p/>
                <h:graphicImage library="images" name="spinning-wait-icons/wait30trans.gif" width="50"/>  
            </p:dialog>   
            <h:form id="clientCreatorForm" >
                <h:panelGroup id="warning">
                    <h:outputText value="WARNING: #{clientCreator.specialInstructions}" styleClass="warning" rendered="#{not empty clientCreator.specialInstructions}" />
                </h:panelGroup>
                <h:outputText value="#{clientCreator.xmlMsgs}"/>
                <h:panelGrid id="op" columns="1">
                    <h:outputText style="height: 20px" />
                    <h:outputText value="Company Information" styleClass="subTitle" />
                    <h:outputText style="height: 10px" />
                    <h:panelGrid id="company" columns="2">
                        <h:outputText value="Select Company:" styleClass="required"/>
                        <p:selectOneMenu value="#{clientCreator.clientCompanyName}" style="width: 400px" >
                            <p:ajax event="itemSelect" 
                                    update="footerPanel,msgs,entitydependencies,entityselect,client,warning"   
                                    listener="#{clientCreator.companyCheck}" />
                            <f:selectItems value="#{clientCreator.companyItemsAvailable}" />
                        </p:selectOneMenu>
                    </h:panelGrid>
                    <h:outputText style="height: 20px" />
                    <p:commandButton id="companyButton" value="Add New Company" rendered="#{menubean.companyCreatorAuthorized}"
                                       action="#{clientCreator.goToCompanyCreator}" />
                    <h:outputText style="height: 20px" />
                    <h:outputText value="Client Information" styleClass="subTitle" />
                    <h:outputText style="height: 10px" />
                    <h:panelGrid id="client" columns="5" >
                        <h:outputText value="First Name:" styleClass="required"/>
                        <p:inputText value="#{clientCreator.client.firstName}" >
                            <p:ajax listener="#{clientCreator.requiredInputTest}" 
                                         event="keyup" 
                                         update="footerPanel" />
                        </p:inputText>
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Last Name:" styleClass="required" />
                        <p:inputText  value="#{clientCreator.client.lastName}" >
                            <p:ajax listener="#{clientCreator.requiredInputTest}"
                                         event="keyup"
                                         update="footerPanel" />
                        </p:inputText>
                        <h:outputText value="E-mail(x@y.z):" styleClass="required" 
                                      rendered="#{!clientCreator.noValidEmail}"/>
                        <h:outputText value="No Valid Email" rendered="#{clientCreator.noValidEmail}"/>
                        <p:inputText id="ClientEmail" value="#{clientCreator.client.email}" disabled="#{clientCreator.noValidEmail}">
                            <p:ajax listener="#{clientCreator.requiredInputTest}"
                                         event="keyup"
                                         update="footerPanel" />
                        </p:inputText>
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Job Title:" />
                        <h:inputText value="#{clientCreator.client.title}" />
                        <h:outputText value="Address:" />
                        <h:inputText value="#{clientCreator.client.address}" />
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Address2:" />
                        <h:inputText id="clientaddr2" value="#{clientCreator.client.address2}" />
                        <h:outputText value="City:" />
                        <h:inputText id="clientcity" value="#{clientCreator.client.city}" />
                        <h:outputText style="width: 40px" />
                        <h:outputText value="State:" />
                        <h:inputText id="clientstate" value="#{clientCreator.client.state}" />
                        <h:outputText value="Postal Code:" />
                        <h:inputText value="#{clientCreator.client.postalCode}" />
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Country:" />
                        <h:inputText value="#{clientCreator.client.country}" />
                        <h:outputText value="Phone:" />
                        <h:inputText value="#{clientCreator.client.phone}" size="40" />
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Ext:" />
                        <h:inputText value="#{clientCreator.client.phoneExt}" size="40" />
                        <h:panelGroup>
                            <h:outputText value="Client PO Number:" rendered="#{clientCreator.clientPONumber eq ''}" />
                        </h:panelGroup>
                        <h:panelGroup>
                            <h:inputText id="po" value="#{clientCreator.clientPONumber}" rendered="#{clientCreator.clientPONumber eq ''}" />
                        </h:panelGroup>
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Client Custom ID 1:" />
                        <h:inputText value="#{clientCreator.client.clientID1}" />
                        <h:outputText value="Client Custom ID 2:" />
                        <h:inputText value="#{clientCreator.client.clientID2}" />
                        <h:outputText style="width: 40px" />
                        <h:outputText value="Client Custom ID 3:" />
                        <h:inputText value="#{clientCreator.client.clientID3}" />
                        <h:panelGroup id="entprojlabel" >
                            <h:outputText value="Legal Entity:" styleClass="required" rendered="#{clientCreator.userSpecificEntity}"/>
                        </h:panelGroup>
                        <h:panelGroup id="entprojlist">
                           <p:selectOneMenu id="entityselect" value="#{clientCreator.client.legalEntity}" rendered="#{clientCreator.userSpecificEntity}">
                                <p:ajax listener="#{clientCreator.entityCheck}"
                                             event="itemSelect" 
                                             update="footerPanel,entitydependencies"/>
                                <f:selectItems value="#{clientCreator.legalEntityItemsAvailable}" />
                            </p:selectOneMenu>
                        </h:panelGroup>
                        <h:outputText style="width: 40px" />
                        <h:outputText value="No Valid EMail?"/>
                        <p:selectBooleanCheckbox value="#{clientCreator.noValidEmail}">
                            <p:ajax event="change" update="client" />
                        </p:selectBooleanCheckbox>
                        <h:outputText value="Username:" styleClass="required"
                                      rendered="#{clientCreator.noValidEmail}"/>
                        <p:inputText value="#{clientCreator.fakeEmailUserName}" 
                                     disabled="#{!clientCreator.noValidEmail}"
                                     rendered="#{clientCreator.noValidEmail}">
                            <p:ajax listener="#{clientCreator.requiredInputTest}"
                                         event="keyup"
                                         update="footerPanel" />
                        </p:inputText>
                    </h:panelGrid>
                    <h:panelGrid id="entitydependencies" columns="2">
                        <h:outputText value="LLS Client ID:" 
                                      rendered="#{clientCreator.entitySet and clientCreator.lls and !clientCreator.clientIDSet}"/>
                        <h:inputText value="#{clientCreator.client.llsClientID}"
                                     rendered="#{clientCreator.entitySet and clientCreator.lls and !clientCreator.clientIDSet}"/>
                        <h:outputText value="Billing Contact Email:" 
                                      rendered="#{clientCreator.entitySet and !clientCreator.lls and !clientCreator.billingEmailSet}"/>
                        <h:inputText value="#{clientCreator.client.billingEmail}" 
                                     rendered="#{clientCreator.entitySet and !clientCreator.lls and !clientCreator.billingEmailSet}"/>
                        <h:outputText value="Special Billing Instructions:" 
                                      rendered="#{clientCreator.entitySet and !clientCreator.lls and !clientCreator.billingInstructionsSet}"/>
                        <h:inputText value="#{clientCreator.client.billingInstructions}" 
                                     rendered="#{clientCreator.entitySet and !clientCreator.lls and !clientCreator.billingInstructionsSet}"/>                       
                    </h:panelGrid>
                    <h:outputText style="height: 20px" />
                    <h:outputText value="Boldface labels mean input is required" styleClass="required"/>
                    <h:outputText style="height: 20px" />
                    <h:panelGrid id="footerPanel" columns="3" >
                        <p:commandButton id="enterbutton" value="Add Client"
                                           action="#{clientCreator.processClient}"
                                           update="footerPanel"
                                           onstart="PF('statusDialog').show('',{top:'100px',left:'400',height:'75px',width:'200px',opacity: '0'})" 
                                           oncomplete="PF('statusDialog').hide()" 
                                           disabled="#{clientCreator.enterDisabled}"/>
                        <p:commandButton id="clearButton" value="Clear" action="#{clientCreator.clear}" />
                        <p:commandButton id="cancelButton" value="Return" action="#{clientCreator.cancel}"
                                           rendered="#{clientCreator.ccClient}" />
                    </h:panelGrid>
                </h:panelGrid>
            </h:form>
            <h1><h:outputText value="You are trying to access one of the LLTS custom apps from outside the Dashboard; this is not permitted. Please log into the dashboard at http://pm.llts.com:9090/LingoApps/faces/menu/menulogon.jsp and access the custom app you want from there."  
                          rendered="#{!(menubean.clientCreatorAuthorized)}"/></h1>
        </f:view>
    </h:body>
</html>

这是从托管bean导航到上述UI的方法。

    public String returnToUserPage() {
        setXmlMsgs("");
        setClientCompanyName(getCompanyName());
        companyCheck();
        getClient().setLegalEntity(getClientCompany().getLegalEntityCompany());
        return "client";
    }

解决方法

确定,我需要做的是在导航时使用重定向选项。例如,上述方法应以

结尾

return "client?faces-redirect=true"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-