【问题标题】:a4j:support onchange event not firinga4j:支持 onchange 事件不触发
【发布时间】:2012-07-18 17:25:57
【问题描述】:

当我更改第一个下拉列表中的值时,我正在尝试重新呈现第二个下拉列表。 但是当我单击并更改第一个下拉列表中的值时,什么也没有发生。 我是否遗漏了任何关键部分?

我的 xhtml:

<h:form>
    <h:selectOneMenu value="#{adminBean.currentLeadCategory}" required="true" styleClass="formfield fpgeo" style="width:20em;margin-right:20px;">
        <a4j:support event="onchange" action="#{adminBean.currentLeadCategoryChanged()}"
 reRender="componentToReRender"/>
        <s:selectItems value="#{leadCategories}" var="leadCategory" label="#{leadCategory.name}" noSelectionLabel="Choose Category"/>
        <s:convertEntity/>
    </h:selectOneMenu>

<a4j:outputPanel id="componentToReRenderWrapper">

    <h:selectOneMenu id="componentToReRender" value="#{adminBean.currentCounty}"
 styleClass="formfield fpgeo" style="width:20em;margin-right:20px;">
        <s:selectItems value="#{adminBean.counties}" var="county" label="#{county.name}" noSelectionLabel="choose"/>
        <s:convertEntity/>
    </h:selectOneMenu>
<h:messages/>
</a4j:outputPanel>
</h:form>

我的豆子:

@AutoCreate
@Scope(ScopeType.CONVERSATION)
@Name("adminBean")
@MeasureCalls
@Restrict("#{s:hasRole('admin') or s:hasRole('sales')}")
public class AdminBean implements Serializable {

    private LeadCategory currentLeadCategory;
    private List<County> counties = new ArrayList<County>();
    private County currentCounty;

@Factory(value = "leadCategories", autoCreate = true, scope = ScopeType.SESSION)
    public List<LeadCategory> fetchLeadCategories() {
        Query query = entityManager.createQuery("select l from LeadCategory l");
        return query.getResultList();
    }

public LeadCategory getCurrentLeadCategory() {
        return currentLeadCategory;
    }

    public void setCurrentLeadCategory(LeadCategory currentLeadCategory) {
        this.currentLeadCategory = currentLeadCategory;
    }

    public County getCurrentCounty() {
        return currentCounty;
    }

    public void setCurrentCounty(County currentCounty) {
        this.currentCounty = currentCounty;
    }

    public void currentLeadCategoryChanged() {
        this.loadCountiesForCategory();
    }

    public List<County> getCounties() {
        return counties;
    }

    public void setCounties(List<County> counties) {
        this.counties = counties;
    }

    public void loadCountiesForCategory(){
        if(currentLeadCategory == null){
            counties = new ArrayList<County>();
        }
        counties = new ArrayList<County>(currentLeadCategory.getCounties());
    }


}

编辑 1:

如果我检查萤火虫我得到一个错误: 时间戳:7/19/12 下午 4:14:44 错误:ReferenceError:未定义 A4J 源文件:http://localhost:8080/admin/admin.seam?cid=11 行:1

【问题讨论】:

    标签: java seam jsf-1.2 ajax4jsf


    【解决方案1】:

    好的,找到问题了!这里发生了重大的疯狂。有人设置了 LoadScriptStrategy web.xml 中的参数为 NONE。这使得 framework.pack.js 和 ui.pack.js 正在加载。

    <context-param>
    <param-name>org.richfaces.LoadScriptStrategy</param-name>
    <param-value>NONE</param-value>
    </context-param>
    

    docs.jboss找到此页面

    如果您使用“NONE”策略,则必须包含以下脚本 在您的 portlet 或门户页面标题中。如果您使用的是 JBoss 门户, 您可以将其添加到 jboss-portlet.xml 文件中。

    已添加&lt;a4j:loadScript src="resource:///org/ajax4jsf/framework.pack.js"/&gt; 对于我的标题模板和中提琴,一切都像魅力一样。

    我热爱我的工作 =)

    【讨论】:

      【解决方案2】:

      我可以清楚地看到你的xhtml有一个结束标签&lt;/a4j:outputPanel&gt;但没有开始标签:&lt;a4j:outputPanel&gt;
      如果您重新排列标签,它将起作用。

      【讨论】:

        猜你喜欢
        • 2012-06-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多