相关疑难解决方法(0)

带有<f:ajax>的JSF2.0仅工作一次

我在JSF2.0中的标记有问题,希望有人指出我做错了什么。这是用户界面中的内容:

<h:panelGroup>
  <h:form id="theForm">
    <h:selectOneMenu id="theMenu" value="#{viewBean.selectedItem}">
        <f:ajax event="change" render="selectedItemText"/>
    <f:selectItem itemLabel=""/>
    <f:selectItems value="#{viewBean.selectableItems}"/>
    </h:selectOneMenu>
    <h:outputText id="selectedItemText" value="#{viewBean.selectedItemText}" />
  </h:form>
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)

这很好用-我的对话范围内的支持bean有一个方法setSelectedItem,它被调用,并且在我第一次从菜单中选择另一个项目时就可以完成它;输出文本在前端更新,很高兴。但是,对菜单选择的进一步更改不会通过ajax触发对设置程序的调用。我也在f:ajax标签上的侦听器上进行了尝试-侦听器方法也仅在第一次调用(代码中的断点才能弄清楚)。

我做错了什么吗?

jsf jsf-2

5
推荐指数
2
解决办法
6242
查看次数

h:commandButton在h:dataTable中不起作用

我试图执行一个action通过commandButton内部的dataTable,但action在时不调用commandButton被放置在数据表中,如下图所示

<h:form>
    <h:dataTable value="#{bean.list}" var="item">
        <h:column>
            <h:commandButton value="submit" action="#{bean.submit}" />
        </h:column>
    </h:dataTable>
</h:form>
Run Code Online (Sandbox Code Playgroud)

当我commandButton移出时dataTable,action成功执行.数据表内部有什么问题commandButton?该commandLink有同样的问题.

datatable jsf commandlink jsf-2 commandbutton

5
推荐指数
1
解决办法
9594
查看次数

更改事件后,JSF ajax事件队列对action-event不起作用

支持的JSF 2.x顺序处理多个ajax事件的功能对我来说不起作用.我有以下场景:

  1. h:inputText(CHANGE)

    <h:inputText id="consumption_input"
       value="#{cc.attrs.consumptionInfo.consumption}">
      <f:ajax
         render="#{cc.attrs.outerRenderString}"
         event="change" listener="#{cc.handleAjaxRequest}" />
    </h:inputText>
    
    Run Code Online (Sandbox Code Playgroud)
  2. h:commandButton(ACTION)

    <h:commandButton
        id="startComparisonButton"
        action="#{rateComparisonBean.startRateComparison()}"
        value="#{bundle.rateResultOverview_startComparison}">
        <!-- This is to avoid mixed requests, ajax and full requests -->
           <f:ajax render="@form"/>
        </h:commandButton>
    
    Run Code Online (Sandbox Code Playgroud)

如果它们自己触发,则两个元素的事件都会被正确处理.

在一次单击中触发两个事件时出现问题(在textInput中输入值,然后单击按钮).我预计这导致两个同步触发的ajax请求(CHANGE-TextField和ACTION-commandButton).

不幸的是,只有一个Ajax-Request(Change-TextField),第二个事件似乎完全丢失了.

我已经确保所有前提条件啊:commandButton都是完全填充的,如下所示: commandButton/commandLink/ajax action/listener方法未被调用或输入值未更新

我很高兴得到任何关于如何解决这个问题的提示.

环境:Glassfish 3,Mojarra 2.1.3-FCS

ajax jsf jsf-2 commandbutton

5
推荐指数
1
解决办法
4204
查看次数

JSF2复合组件为action方法抛出PropertyNotFoundException

我有一个复合组件:

<composite:interface>
    <composite:attribute name="actionMethod" 
        method-signature="java.lang.String action()" required="true" />
</composite:interface>

<composite:implementation>
    <h:form>
        <h:commandButton id="captureButton" value="#{msgs.capture}" 
            action="#{cc.attrs.actionMethod}" />
    </h:form>
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)

和一个调用该复合组件的页面:

<ezcomp:captureTitle actionMethod="#{saveDecisionsBean.captureTitle}" />
Run Code Online (Sandbox Code Playgroud)

和一个包含动作的bean:

@Named(value="saveDecisionsBean")
@SessionScoped
public class SaveDecisionsBean extends BackingBeanBase {
    ...
    public String captureTitle() {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

现在这是我的问题.当我尝试运行它时,它说SaveDecisionsBean没有属性captureTitle.因此,我必须添加一个SaveDecisionsBean#getCaptureTitle()方法.当我这样做时,它运行得很好.我为什么要定义这个方法?它说它<composite:attribute />是一种方法,它被用作一种动作.

这是我得到的确切错误消息:

javax.el.PropertyNotFoundException: /index.xhtml @54,86 
    actionMethod="#{saveDecisionsBean.captureTitle}": 
    The class 'com.example.persistence.SaveDecisionsBean_$$_javassist_209'
    does not have the property 'captureTitle'.
Run Code Online (Sandbox Code Playgroud)

(出于SEO原因:其他实现可能会显示类名WeldClientProxy.)

jsf composite-component jsf-2

4
推荐指数
1
解决办法
8353
查看次数

JSF Action Method未被调用

我有一个带有Primefaces数据表和命令按钮的JSF视图,作为休闲:

<p:messages id="statusMessages" showDetail="true" />
    <h:form id="listForm">
        <p:panel header="Wellsite List">
            <br />
            <h:outputLabel value="Welcome, #{wellsiteController.loggedUser.login}" />
            <br />
            <br />

            <p:dataTable id="dataTable" var="wellsite" value="#{wellsiteController.wellsiteDataTableModel}"
                         paginator="true" rows="10" selection="#{wellsiteController.wellsite}">

                <p:column selectionMode="single" style="width:18px" id="radioSelect" />

                <p:column sortBy="#{wellsite.reference}" headerText="Wellsite ID">
                    <h:outputText value="#{wellsite.reference}" />
                </p:column>

                <p:column headerText="Allowed Groups">
                    <h:outputText value="#{wellsite.allowedGroups.toString()}" />
                </p:column>

                <f:facet name="footer">
                    <h:panelGrid columns="3">
                        <p:commandButton id="addWellsite" value="Add New Wellsite" icon="ui-icon-flag" ajax="false" action="#{wellsiteController.showAddWellsite}"/>
                        <p:commandButton id="editWellsite" value="Edit Selected Wellsite" icon="ui-icon-wrench" ajax="false" action="#{wellsiteController.showEditWellsite}"/>

                        <p:commandButton id="deleteWellsiteButton" value="Remove Selected Wellsite" icon="ui-icon-trash" onclick="confirmation.show()" type="button"/>

                    </h:panelGrid>
                </f:facet>
            </p:dataTable>
            <p:spacer height="20" …
Run Code Online (Sandbox Code Playgroud)

methods jsf action

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

primefaces commandbutton actionlistener not called

I am using primefaces 3.0 and jsf 2.0.
I have prepared client master which add client using wizard and at the same time reflected in datatable. Then I have updated edit utility in datatable. Then I have added delete button in datatable and try call delete method of bean.
But when I click on delete button wizard validation for adding client is executed. So I have created another file ClientEditdatatable.xhtml and included in clientmaster.xhtmlbut same result remain. Now …

actionlistener primefaces jsf-2

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

有条件地呈现的输入组件不更新值

使用jsf 2和Primefaces 3.4

我知道有很多类似的问题,但没有一个在这个问题上有效.

当单击命令按钮后,panelGrid"inner"以固定值"true"(<h:panelGrid id="inner" rendered="true">)=> 呈现时,输入组件正确更新#{tableMatchesBean.mergedAuthorAjax}的值,

但是当此面板的呈现是有条件的时:<h:panelGrid rendered="#{spellCheckBean.renderInputMerge}"> =>然后输入组件是静默的(没有跟踪tableMatchesBean.mergedAuthorAjax已被调用).

注意:我使用嵌套的panelGrids将渲染条件放在需要有条件渲染的组件的父元素(输出和输入组件)中.任何帮助赞赏.

[评论后编辑:] xhtml页面的作用:
- 当用户点击selectOnebutton中的"merge"选项时,ajax更新会将"renderInputMerge"切换为true,从而导致显示"外部"组件.它工作正常.在此组件中,有一个输入字段,显示OK.
- 在用户单击commandLink按钮后,我需要检索此输入字段的值.如上所述,我有一个问题.

xhtml:

<h:body style ="width:100%">


    <h:form id = "currMatch">

        <h:panelGrid>

            <p:selectOneButton id ="selection" value="#{spellCheckBean.optionChosen}">
                <f:selectItem itemLabel="keep both" itemValue="1" />
                <f:selectItem itemLabel="delete both" itemValue="2" />
                <f:selectItem itemLabel="merge" itemValue="3" />
                <p:ajax update="outer" />
            </p:selectOneButton>

        </h:panelGrid>

         <h:panelGrid id="outer" >
            <h:panelGrid id="inner" rendered="#{spellCheckBean.renderInputMerge}">
            <!-- **the line above does not update**, this one does    <h:panelGrid rendered="true">-->

                <h:outputText …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces jsf-2

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

如何在JSF中创建切换按钮?

如何在JSF中创建切换按钮?

基本上,我需要两个按钮“ in”和“ out”。它们本质上调用了相同的托管Bean,但是由于每次单击,都应禁用一个,而应启用另一个,反之亦然。如何才能做到这一点?我应该使用ajax功能吗?

jsf toggle jsf-2 commandbutton

4
推荐指数
1
解决办法
5377
查看次数

Primefaces咆哮不适用于所有页面

我的网站有一个共同的模板,即xhtml file同时包含growl

<p:growl id="message" showDetail="true" life="3000" />
Run Code Online (Sandbox Code Playgroud)

该模板将在所有页面中进一步使用。我注意到这growl适用于页面,index.xhtml但不适用于其余页面。以下是faces-config.xml文件的摘要-

<navigation-rule>
    <display-name>index.xhtml</display-name>
    <from-view-id>/index.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>NORMAL_USER</from-outcome>
        <to-view-id>/home.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>
Run Code Online (Sandbox Code Playgroud)

但是,每当我home.xhtml通过link 访问页面时http://localhost:8080/portal/home.xhtml,便 growl开始工作。在我update=":message"用来更新的所有页面中growl。罪魁祸首是哪个?

下边是 index.xhtml

<ui:composition template="/template/common/base.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

    <ui:define name="center">

        <h:form>
            <div align="center" style="margin-top: 10%; margin-bottom: 10%;">
                <p:panelGrid columns="2">
                    <f:facet name="header">  
                     #{msg.HEADER}
                    </f:facet>

                    <h:outputLabel for="username" value="#{msg.USERNAME}" />
                    <p:inputText id="username" value="#{client.user.username}"
                        required="true" requiredMessage="#{msg.USERNAME_REQUIRED_MSG}" />

                    <h:outputLabel for="password" value="#{msg.PASSWORD} " />
                    <p:password id="password" value="#{client.user.password}"
                        required="true" …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

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

填写输入字段时重新启用禁用的命令按钮

我需要启用/禁用JSF 2.0页面上的按钮,具体取决于用户是否在文本区域中输入了文本.

但是,在启用/禁用按钮的同时,不会调用该操作.

这是代码:

<script>
                                function countChar() {
                                    var val = findElement('inputNoteTextArea');
                                    var len = val.value.length;
                                    var maxLen = 400;
                                    var charLeft;
                                    $('#charNum').text(
                                            'Note:' + maxLen + ' characters left  out of ' + maxLen);
                                    if (len >= maxLen) {
                                        val.value = val.value.substring(0, maxLen);
                                        $('#charNum').text(' you have reached the limit');
                                        document.getElementById('noteSubmitButton').disabled = false;
                                    } else if (len > 0 ){
                                        charLeft = maxLen - len;
                                        $('#charNum').text(
                                                'Note :' + charLeft
                                                        + ' characters left  out of ' + maxLen);
                                        document.getElementById('noteSubmitButton').disabled …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jsf jsf-2

4
推荐指数
1
解决办法
4433
查看次数