JBoss - onblur 事件调用的函数未给出任何结果或警报

发布于 2024-12-21 01:18:57 字数 4224 浏览 3 评论 0原文

我的 JSP 中有几个文本框。我的要求(对于其中一个文本框)是检查用户在其中输入的数据的长度,如果它小于最大长度,我需要前缀那么多零并使其达到最大长度。

我有一些具有现有功能的现有代码。

我刚刚在 onblur 事件中添加了一些部分。从下面的代码中可以看出,我尝试在发生 onblur 时设置 zrs 变量的值。

zrs 变量又通过调用 zeros() 函数来设置。

我粘贴了下面的 zeros() 函数代码以供参考。

值得注意的是,当我在 Weblogic 服务器上部署代码时,它运行良好。它甚至给了我正确的结果以及作为 Zeros 功能的一部分添加的警报。

但是当我在 JBoss 上部署相同的内容时,它也没有发出任何警报。 我对这两个应用程序都使用 Internet Explorer,它们构建于 Web Logic 和 JBoss 之上。

有人可以调查一下并指导我吗?

<c:choose>
    <c:when test="${dto.loadpage == true}">
                                            <input type="hidden" name="tmpValue[<c:out value="${indexDto}"/>]"  value="<c:out value="${dto.valeurSaisiForm}"/>"/>
                                            <c:set var="prop" value="calculer(this,${dto.valMaxChamp},'${nomDuChamp}',${indexDto});"/>
                                            <c:set var="zrs" value ="zeros(this,${dto.valMaxChamp},'${nomDuChamp}',${indexDto});"/>
                                            <input <c:out value="${optionChampInterdit}"/> type="text" name="dto[<c:out value="${indexDto}"/>].valeurSaisiForm" onfocus="change_classe_byId(this,'on');"
                                            onclick="SetSelectedControl(this,'<%= nomDuChamp %>');" style="<%=style%>" maxlength="<%=max%>" 
                                            onblur="<c:out value="${zrs}"/>;change_classe_byId(this,'off');" onchange="<c:out value="${prop}"/>" onkeyup="<c:out value="${prop}"/>" class="<c:out value="${styleClass}"/>"  value="<c:out value="${dto.valeurSaisiForm}"/>" />
    </c:when>
    <c:otherwise>
                                            <input <c:out value="${optionChampInterdit}"/> type="text" id="<c:out value="${dto.nomChamp}"/>" name="dto[<c:out value="${indexDto}"/>].valeurSaisiForm" onfocus="change_classe_byId(this,'on');"
                                            onclick="SetSelectedControl(this,'<%= nomDuChamp %>');" style="<%=style%>" maxlength="<%=max%>" 
                                            onblur="<c:out value="${zrs}"/>;change_classe_byId(this,'off');"   class="<c:out value="${styleClass}"/>"  value="<c:out value="${dto.valeurSaisiForm}"/>" /> 
                                                    
                                            
    </c:otherwise>
                                    
</c:choose>

功能:

function calculer(obj, max,field, indexTmp){
            var nameTmp = "tmpValue["+indexTmp+"]";
            if(obj!=null && ((obj.value.length== max) || (obj.value.length== 0)) && this.document.Bean.elements[nameTmp]!=null &&
                   this.document.Bean.elements[nameTmp].value!=obj.value){
                this.document.Bean.elements[nameTmp].value = obj.value;
            setTemplate(field);
            }

        }
    
    function zeros(obj, max, field,indexTmp)
    {
        alert("Inside Zeros - onBlur Called----Current Value is "+obj.value);
                
    
        var nameTmp = "tmpValue["+indexTmp+"]";
        
        if (field.substring(0,8) == "PDPMODEL")     
        {
            alert("Field is PDPMODEL");
            if(obj!=null && obj.value.length < max && obj.value.length != 0 && this.document.Bean.elements[nameTmp]!=null)
            {
            
                alert("Zeros Prefix Needed");
                var prfx="";
                for(var cnt= obj.value.length; cnt < max ; cnt++)
                {
                    prfx=prfx+"0";
                }
                
                obj.value = prfx + obj.value;
                alert("New value is "+obj.value);
                
                this.document.Bean.elements[nameTmp].value = obj.value;
                setTemplate(field);
        
                
            }
            change_classe_byId(obj,'off');
            
        }
        
        change_classe_byId(obj,'off');
        
    }

I have few text boxes in my JSP. My requirement (for one of the text boxes) is to check the length of data entered by user in it, if it is less than the Max Length, I need to Prefix that many Zeros and Make it of Max Length.

I had some existing code with existing functionality.

I have just added some part in onblur event. As can be seen in the code below, I have tried to set the value from zrs variable when onblur occurs.

The zrs variable is in turn being set by calling a zeros() function.

I have pasted the code below for zeros() function for the reference.

It's worth noting that, when I am deploying my code on Weblogic server, it works fine. It even gives me correct results and also the alerts added as part of Zeros function.

But when I am deploying the same on JBoss, it does not give any alerts as well.
I am using Internet Explorer for both the applications, built on Web Logic and JBoss.

Can someone please look into it and guide me?

<c:choose>
    <c:when test="${dto.loadpage == true}">
                                            <input type="hidden" name="tmpValue[<c:out value="${indexDto}"/>]"  value="<c:out value="${dto.valeurSaisiForm}"/>"/>
                                            <c:set var="prop" value="calculer(this,${dto.valMaxChamp},'${nomDuChamp}',${indexDto});"/>
                                            <c:set var="zrs" value ="zeros(this,${dto.valMaxChamp},'${nomDuChamp}',${indexDto});"/>
                                            <input <c:out value="${optionChampInterdit}"/> type="text" name="dto[<c:out value="${indexDto}"/>].valeurSaisiForm" onfocus="change_classe_byId(this,'on');"
                                            onclick="SetSelectedControl(this,'<%= nomDuChamp %>');" style="<%=style%>" maxlength="<%=max%>" 
                                            onblur="<c:out value="${zrs}"/>;change_classe_byId(this,'off');" onchange="<c:out value="${prop}"/>" onkeyup="<c:out value="${prop}"/>" class="<c:out value="${styleClass}"/>"  value="<c:out value="${dto.valeurSaisiForm}"/>" />
    </c:when>
    <c:otherwise>
                                            <input <c:out value="${optionChampInterdit}"/> type="text" id="<c:out value="${dto.nomChamp}"/>" name="dto[<c:out value="${indexDto}"/>].valeurSaisiForm" onfocus="change_classe_byId(this,'on');"
                                            onclick="SetSelectedControl(this,'<%= nomDuChamp %>');" style="<%=style%>" maxlength="<%=max%>" 
                                            onblur="<c:out value="${zrs}"/>;change_classe_byId(this,'off');"   class="<c:out value="${styleClass}"/>"  value="<c:out value="${dto.valeurSaisiForm}"/>" /> 
                                                    
                                            
    </c:otherwise>
                                    
</c:choose>

Functions :

function calculer(obj, max,field, indexTmp){
            var nameTmp = "tmpValue["+indexTmp+"]";
            if(obj!=null && ((obj.value.length== max) || (obj.value.length== 0)) && this.document.Bean.elements[nameTmp]!=null &&
                   this.document.Bean.elements[nameTmp].value!=obj.value){
                this.document.Bean.elements[nameTmp].value = obj.value;
            setTemplate(field);
            }

        }
    
    function zeros(obj, max, field,indexTmp)
    {
        alert("Inside Zeros - onBlur Called----Current Value is "+obj.value);
                
    
        var nameTmp = "tmpValue["+indexTmp+"]";
        
        if (field.substring(0,8) == "PDPMODEL")     
        {
            alert("Field is PDPMODEL");
            if(obj!=null && obj.value.length < max && obj.value.length != 0 && this.document.Bean.elements[nameTmp]!=null)
            {
            
                alert("Zeros Prefix Needed");
                var prfx="";
                for(var cnt= obj.value.length; cnt < max ; cnt++)
                {
                    prfx=prfx+"0";
                }
                
                obj.value = prfx + obj.value;
                alert("New value is "+obj.value);
                
                this.document.Bean.elements[nameTmp].value = obj.value;
                setTemplate(field);
        
                
            }
            change_classe_byId(obj,'off');
            
        }
        
        change_classe_byId(obj,'off');
        
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

未蓝澄海的烟 2024-12-28 01:18:57

只是为了澄清:
应用程序服务器(jboss/weblogic 等)只是生成 html 页面,并在浏览器中呈现
因此,java 脚本也在浏览器内运行,它完全是客户端。

话虽如此,我建议您比较 html 输出作为解决此问题的第一次尝试(只需在浏览器中创建“查看源代码”,您知道......)
您应该看到由 JBOSS 创建的页面和由 WebLogic 创建的页面的不同输出。

我最初的猜测是这里的 JSTL 有问题,可能这两个应用服务器支持不同版本的 JSTL。
如果是这样的话
也许你应该修改 jstl 的标头,我知道有时在 JBOSS 中它会有所帮助。
只需查看您的 WEB 版本的 JSTL 示例即可。

希望这有帮助

Just to clarify:
The application server (jboss/weblogic whatsoever) just produces your html page that gets rendered inside your browser.
So, java script also runs inside your browser, its totally client side.

Having said that, I would suggest you to compare the html output as a first attempt to solve this issue (just make a "view source" in your browser, you know...)
You should see different output of the page, created by JBOSS and the one created by WebLogic.

My initial guess is that something wrong with JSTL here, maybe different versions of JSTL are supported by these two application servers.
If its so,
probably you should modify headers of jstl, I know sometimes in JBOSS it helps.
Just take a look on JSTL example of your version in WEB.

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文