JSF 2.2 SelectManyCheck 破坏了 javascript

2023-12-19

它曾经在 jsf 2.0 上完美工作,但知道它会在屏幕末尾呈现一个框,其中包含一个包含位置数据的 html 表,如果我删除转换器,则 selectmany 复选框有效,但它仍然呈现该框。

<ui:composition template="/template.xhtml">
    <ui:define name="title">
        <h:outputText value="#{bundle.CreateOfertaTitle}"></h:outputText>
    </ui:define>
            <ui:define name="body">
                <style type="text/css">
            input#chat {
                width: 410px
            }

            #console-container {
                width: 400px;
            }

            #console {
                border: 1px solid #CCCCCC;
                border-right-color: #999999;
                border-bottom-color: #999999;
                height: 170px;
                overflow-y: scroll;
                padding: 5px;
                width: 100%;
            }

            #console p {
                padding: 0;
                margin: 0;
            }
        </style>
                    <script type="text/javascript">
            var Chat = {};

            Chat.socket = null;

            Chat.connect = (function(host) {
                if ('WebSocket' in window) {
                    Chat.socket = new WebSocket(host);
                } else if ('MozWebSocket' in window) {
                    Chat.socket = new MozWebSocket(host);
                } else {
                    Console.log('Error: WebSocket is not supported by this browser.');
                    return;
                }

                Chat.socket.onopen = function() {
                    Console.log('Info: WebSocket connection opened.');
                    document.getElementById('chat').onkeydown = function(event) {
                        if (event.keyCode == 13) {
                            Chat.sendMessage();
                        }
                    };
                };

                Chat.socket.onclose = function() {
                    document.getElementById('chat').onkeydown = null;
                    Console.log('Info: WebSocket closed.');
                };

                Chat.socket.onmessage = function(message) {
                    Console.log(message.data);
                };
            });

            Chat.initialize = function() {
                if (window.location.protocol == 'http:') {
                    Chat.connect('ws://' + window.location.host + '/Formosa2/endpoint');
                } else {
                    Chat.connect('wss://' + window.location.host + '/Socket/websocket/chat');
                }
            };

            Chat.sendMessage = (function() {
                var ofertaTexto = document.getElementById('form:texto').value;
                var select = document.getElementById('form:empresaidEmpresa');
                var barrio = document.getElementById('inicio_input').value;

                var nombreEmpresa = select.options[select.selectedIndex].text;
                    Chat.socket.send(ofertaTexto +', '+ nombreEmpresa+','+ barrio);
                    document.getElementById('chat').value = '';

            });

            var Console = {};

            Console.log = (function(message) {
                var console = document.getElementById('console');
                var p = document.createElement('p');
                p.style.wordWrap = 'break-word';
                p.innerHTML = message;
                console.appendChild(p);
                while (console.childNodes.length > 25) {
                    console.removeChild(console.firstChild);
                }
                console.scrollTop = console.scrollHeight;
            });

            Chat.initialize();

        </script>
        <h:panelGroup id="messagePanel" layout="block">
            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
        </h:panelGroup>
        <h:form id="form" enctype="multipart/form-data">
            <h:outputLabel rendered="#{usuarioController.userSession.isLoggedIn}"
            value="#{usuarioController.userSession.sessionId}"/>
            <h:panelGrid columns="2">
                <h:outputLabel value="#{bundle.CreateOfertaLabel_texto}" for="texto" />
                <h:inputText id="texto" value="#{ofertaController.selected.texto}" title="#{bundle.CreateOfertaTitle_texto}" />

                <h:outputLabel value="#{bundle.CreateOfertaLabel_inicio}" for="inicio" />
                <t:inputCalendar id="inicio" value="#{ofertaController.selected.inicio}" renderAsPopup="true"
                                 popupTodayString="Hoy" popupDateFormat="MM/dd/yyyy" 
                                 popupWeekString="Semana" helpText="MM/DD/YYYY" forceId="true"/>

                <h:outputLabel value="#{bundle.CreateOfertaLabel_fin}" for="fin" />                   
                <t:inputCalendar id="fin" value="#{ofertaController.selected.fin}" renderAsPopup="true"
                                 popupTodayString="Hoy" popupDateFormat="MM/dd/yyyy" 
                                 popupWeekString="Semana" helpText="MM/DD/YYYY" forceId="true"/>

                <h:outputLabel value="#{bundle.CreateOfertaLabel_titulo}" for="titulo" />
                <h:inputText id="titulo" value="#{ofertaController.selected.titulo}" title="#{bundle.CreateOfertaTitle_titulo}" />
                <h:outputLabel value="#{bundle.CreateOfertaLabel_imagen}" for="imagen" />
                <h:inputFile id="imagen" value="#{ofertaController.upLoad.upFile}" title="#{bundle.CreateOfertaTitle_imagen}"/>

                <h:outputLabel value="#{bundle.CreateOfertaLabel_empresaidEmpresa}" for="empresaidEmpresa" />                                        
                <h:selectOneMenu id="empresaidEmpresa" 
                                 value="#{ofertaController.selected.empresaidEmpresa}" 
                                 title="#{bundle.CreateOfertaTitle_empresaidEmpresa}"
                                 required="true" 

                                 requiredMessage="#{bundle.CreateOfertaRequiredMessage_empresaidEmpresa}">
                    <f:ajax event="valueChange" execute="empresaidEmpresa" render="ubicacionCollection" />
                    <f:selectItems value="#{empresaController.itemsAvailableSelectOne}"/>
                </h:selectOneMenu>

                <h:outputLabel value="#{bundle.CreateOfertaLabel_ubicacionCollection}" for="ubicacionCollection" />      
                <h:selectManyCheckbox id="ubicacionCollection"
                                      value="#{ofertaController.selected.ubicacionCollection}"
                                      title="#{bundle.CreateOfertaTitle_ubicacionCollection}" >

                    <f:selectItems id="ubicacionCollectionItems"
                                   value="#{ofertaController.selected.empresaidEmpresa.ubicacionCollection}"
                                   var="ubicacionXEmpresa"
                                   itemLabel="#{ubicacionXempresa.barrio}"
                                   itemValue="#{ubicacionXEmpresa}"/>
               </h:selectManyCheckbox>
            </h:panelGrid>
            <br />
                <br />
                <br />
                <noscript><h2 style="color: #ff0000">Seems your browser doesn't 
                        support Javascript! Websockets rely on Javascript being enabled. Please enable
                        Javascript and reload this page!</h2></noscript>
                <div>
                    <p>
                        <input type="text" placeholder="type and press enter to chat" id="chat"/>
                    </p>

                    <div id="console-container">
                        <div id="console"></div>
                    </div>
                </div>
            <h:commandLink action="#{ofertaController.create}" value="#{bundle.CreateOfertaSaveLink}" onclick='Chat.sendMessage();'/>
            <br />
            <br />
            <h:commandLink action="#{ofertaController.prepareList}" value="#{bundle.CreateOfertaShowAllLink}" immediate="true"/>
            <br />
            <br />

        </h:form>
    </ui:define>
</ui:composition>

我的转换器:

@FacesConverter(value = "ubicacionConverter")
public class UbicacionesBYOfertasConverter implements Converter {

private FacesContext facesContext = FacesContext.getCurrentInstance();
private OfertaController ofertaController = (OfertaController) facesContext.getApplication()
            .evaluateExpressionGet(facesContext, "#{ofertaController}", OfertaController.class);

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if (value == null) {
        return null;
    }
    System.out.println(value);
    Ubicacion ubicacion = ofertaController.getSelected().getEmpresaidEmpresa().getUbicacionCollection().iterator().next();        
    ofertaController.getSelected().setUbicacionCollection(ofertaController.getSelected().getEmpresaidEmpresa().getUbicacionCollection());
    return ubicacion;
}

@Override
public String getAsString(FacesContext context, UIComponent component,
        Object value) {
    String string = null;
    if (value instanceof Integer) {
        string = String.valueOf(ofertaController.getSelected().getEmpresaidEmpresa().getUbicacionCollection().iterator().next().getIdUbicacion());
    }
    return string;
}   
}

JavaScript 异常

Uncaught TypeError: Cannot read property 'length' of null jsf.js?       ln=javax.faces&stage=Development:362
contains jsf.js?ln=javax.faces&stage=Development:362
FrameTransport.cleanupReqParams jsf.js?ln=javax.faces&stage=Development:351
FrameTransport.callback jsf.js?ln=javax.faces&stage=Development:335
(anonymous function) jsf.js?ln=javax.faces&stage=Development:380
FrameTransport.open jsf.js?ln=javax.faces&stage=Development:242
AjaxEngine.req.sendRequest jsf.js?ln=javax.faces&stage=Development:1794
sendRequest jsf.js?ln=javax.faces&stage=Development:2440
request jsf.js?ln=javax.faces&stage=Development:2450 
ab jsf.js?ln=javax.faces&stage=Development:3255
onchange List.xhtml:169

输入文件大多数是像这样的其他形式

<h:form enctype="multipart/form-data">                                
                            <p:fileUpload value="#{contratosMB.fileContrato}" mode="simple" />  
                            <p:commandButton value="Cargar Archivo" ajax="false"  
                            actionListener="#{contratosMB.upload}" icon="ui-icon-arrowreturn-1-n"/>  
</h:form>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JSF 2.2 SelectManyCheck 破坏了 javascript 的相关文章

随机推荐

  • Helm 动态设置 Docker 镜像标签

    我使用以下命令通过 Jenkins 将 Docker 镜像推送到我们的私有注册表 def dockerImage docker build repo myapp env BUILD NUMBER BUILD NUMBER每次构建后都会增加
  • 带进度条报告的stream.copyto

    我想合并 2 个大文件 但 atm 我的代码仅在复制 1 个文件后更新进度是否有更好的方法来报告进度这是我的复制代码 atm max files Count MessageBox Show Merge Started using Strea
  • 在 .NET DrawString 中换行时禁用断字

    我正在使用 NET 将字符串绘制到有限的空间中 我希望字符串尽可能大 我对字符串分成更多行没有问题 如果它留在矩形内 现在的问题是 我不希望 NET 在单词中间的不同行中断开字符串 例如 字符串 Test 以大字体打印在一行上 字符串 Te
  • Android 项目错误任务 ':transformClassesWithJarMergingForDebug' 执行失败

    我正在将我的 Android 应用程序从 Eclipse 转换为 Android Studio 当我构建 gradle 时没有错误 但在运行应用程序时 我遇到了以下错误 Error Execution failed for task tra
  • 来自 Firefox 的 ajax 调用未加载 SSL 客户端证书

    我正在从 HTTP 页面执行 CORS 请求 其中包括对另一个 HTTPS 服务器的 JQuery ajax 调用 该服务器向客户端请求 SSL 客户端证书 因此 ajax 查询需要提供它 在 Chrome 35 中 一切都按预期工作 并且
  • 如何为表面着色以具有更强的对比度

    在Matlab中 我尝试使用以下代码在2维欧几里得空间上绘制一个函数 s 05 x 2 s 2 s y 1 s 3 s X Y meshgrid x y Z 1 X 2 100 Y X X 2 surf X Y Z colormap jet
  • 当 php 应用程序位于 Varnish 后面时使用 Xdebug

    我正在尝试使用 PHPStorm 将 Xdebug 远程调试设置为位于 Varnish 后面的站点作为缓存层 Varnish 作为端口 80 上的前端 Apache 作为端口 8080 上的后端与之通信 如果我绕过 Varnish 并直接与
  • 评估“可变变量”

    我正在使用以下内容创建一个动态变量 PHP 术语中的 变量变量 foo test1 set to word rejoin foo result data array 5 但是如何动态获取名为 test1 result data 的结果变量的
  • 如何使用 Modernizr 使 border-radius 在 IE8 中工作?

    我知道有很多关于在 IE8 中获取圆角的文章 我的问题是 如何使用Modernizr支持CSS3 HTML5功能 例如 为了在 IE8 中显示圆角 我使用 CSS 3 属性 webkit border radius 20px moz bor
  • 如何在React Native Android中添加自定义字体

    我想设置fontFamily到 roboto 精简我的工具栏标题 我已经添加了roboto Thin ttfassets fonts我的 android 项目的文件夹 但是它似乎在运行应用程序时产生问题 我在运行时遇到这个问题 反应本机启动
  • java cpu使用率监控

    有没有办法使用纯Java来监控CPU使用率 kgiannakakis 链接的文章评论中有一个宝石 javasysmon https github com jezhumble javasysmon wiki JavaSysMon 管理进程和
  • Discord.js V13 发送消息附件

    升级到discord js v13并使用后Array from message attachments values 代替message attachments array 发送消息中的附件 message client channels
  • AWS API Gateway 缓存忽略查询参数

    我正在 AWS API Gateway 端配置缓存以提高 REST API 的性能 我尝试配置的端点正在使用查询参数 我已经在 AWS API Gateway 端启用了缓存 但不幸的是 我发现它在构建缓存键时忽略了查询参数 例如 当我使用查
  • 如何启用 Guard Malloc

    这是一个愚蠢的问题 文档说 要使用 Guard Malloc 启用调试 请在运行项目之前在 Xcode 中选择 运行 gt 启用 Guard Malloc 选项 启用此选项后构建并运行您的应用程序会自动使用 Guard Malloc 库运行
  • 默认 MVC 5 应用程序的安全异常

    将 VS 2013 生成的默认 MVC 5 应用程序部署到我的托管帐户时 我遇到了安全异常 对于这个问题有什么快速的解决办法吗 Description The application attempted to perform an oper
  • Yii2:在字段模糊时禁用 ActiveForm Ajax 验证

    如何自动禁用 Yii validation onblur ajax 验证 我只想在按下提交按钮后进行验证 您想使用enableAjaxValidation验证您的表单 同时不希望在每个表单上触发 ajax 验证blur当您输入该字段后 您只
  • _NET_WM_ICON 的图片格式

    环境 Ubuntu 16 04 在我的应用程序中 我通过调用获取应用程序的图标XGetWindowProperty with NET WM ICON atom unsigned char data XGetWindowProperty da
  • 对空结果集的非法操作[重复]

    这个问题在这里已经有答案了 我正在尝试在一家杂货店建立一个收银台 我的代码实际上执行了我想要它做的事情 但有一点是这样的 在我要求用户输入他们想要的商品数量后 产品信息被收集并且工作正常 但是当它应该要求用户输入下一个产品的产品 ID 时
  • 如何获取视频的完整时长和当前播放时长?

    我需要使用 swift 创建一个自定义视频插件 但我不知道如何获取视频的完整持续时间和当前播放时间 在我的控制台中刚刚出现了这个输出 C CMTime 我不确定我的代码有什么问题 My code let url NSBundle mainB
  • JSF 2.2 SelectManyCheck 破坏了 javascript

    它曾经在 jsf 2 0 上完美工作 但知道它会在屏幕末尾呈现一个框 其中包含一个包含位置数据的 html 表 如果我删除转换器 则 selectmany 复选框有效 但它仍然呈现该框