相关疑难解决方法(0)

使用CompositeComponent的javax.el.PropertyNotFoundException?

我目前正在尝试构建一个复合组件,这就是我如何使用我的组件:


包括它 xmlns:albert="http://java.sun.com/jsf/composite/albert"


这是用法示例

<albert:infoButton
    infoId="infoSingleRecord"
    params="transDateFrom transDateTo"
    mappingMethod="#{tBrowseBean_ConfirmedRPB.mapSendInfoSingleRecord}" />
Run Code Online (Sandbox Code Playgroud)

这是放在resources/albert/infoButton.xhtml中的组件

<?xml version="1.0" encoding="UTF-8"?>
<!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:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:composite="http://java.sun.com/jsf/composite">

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

    <composite:implementation>
        <p:commandButton 
            process="@this #{cc.attrs.params}"
            actionListener="#{cc.attrs.mappingMethod}"
            update="#{cc.attrs.infoId}Panel"
            oncomplete="#{cc.attrs.infoId}Dialog.show()" 
            image="ui-icon ui-icon-search" />
    </composite:implementation>
</html>
Run Code Online (Sandbox Code Playgroud)

但运行它,当单击infoButton时,此异常跟踪显示在我的catalina.out日志文件中:

Apr 25, 2011 10:08:43 AM javax.faces.event.MethodExpressionActionListener processAction
SEVERE: Received 'javax.el.PropertyNotFoundException' when invoking action listener '#{cc.attrs.mappingMethod}' for component 'j_idt71'
Apr 25, 2011 10:08:43 AM …
Run Code Online (Sandbox Code Playgroud)

jsf composite-component jsf-2 propertynotfoundexception

2
推荐指数
1
解决办法
8773
查看次数

多次调用ActionListener(Bug?) - Mojarra 2.1.3

我有以下按钮:

   <h:commandButton 
     disabled="#{mybean.searching}"
     binding="#{mybean.searchButton}"
     actionListener="#{mybean.searchForLicenses}"
     value="Search" />
Run Code Online (Sandbox Code Playgroud)

当我调试时,我看到actionListener首先被调用两次,然后被调用三次,接下来单击四次,依此类推.

似乎每次重新加载时actionListener都会再次注册.

我正在使用Mojarra 2.1.3(也尝试过2.0.6)和Tomcat 7和IceFaces.

绑定是这样完成的:

private javax.faces.component.UICommand searchButton;

public void setSearchButton(UICommand searchButton) {
  this.searchButton = searchButton;
}

public UICommand getSearchButton() {
  return searchButton;
}
Run Code Online (Sandbox Code Playgroud)

jsf icefaces mojarra

2
推荐指数
1
解决办法
5122
查看次数

JSF2:action和actionListener

从这个答案由BalusC这里的行动和ActionListener的差异,Use actionListener if you want have a hook before the real business action get executed, e.g. to log it, and/or to set an additional property (by <f:setPropertyActionListener>,.但是,当我决定编写一些代码来测试它时,结果有点不同.这是我的小代码

<h:form id="form"> 
   <h:panelGroup id="mygroup">
     <p:dataTable id="mytable" value="#{viewBean.foodList}" var="item">
         <p:column>
             #{item}
         </p:column>
         <p:column>
             <p:commandButton value="delete" 
                        action="#{viewBean.delete}"
                        update=":form:mygroup">
                 <f:setPropertyActionListener target="#{viewBean.selectedFood}"
                                              value="#{item}"/>
             </p:commandButton>
         </p:column>
      </p:dataTable>
   </h:panelGroup>
</h:form>
Run Code Online (Sandbox Code Playgroud)

这是我的豆子

@ManagedBean
@ViewScoped
public class ViewBean {
    private List<String> foodList;
    private String selectedFood;

    @PostConstruct
    public void init(){

        foodList = new ArrayList<String>();
        foodList.add("Pizza");
        foodList.add("Pasta");
        foodList.add("Hamburger");
    } …
Run Code Online (Sandbox Code Playgroud)

jsf action actionlistener primefaces jsf-2

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

#{bean.function}和#{bean.function()}有什么区别?

我是JSF的新手.我想知道JSF /导航规则的一点.我有四个页面,索引,p1,p2,p3.当我尝试导航到一个页面,其中action ="#{bean.gotoP1()} ",这是错误的;

"无法找到与from-view-id'/index.xhtml'匹配的导航案例,以便对行动'#{bean.gotoP1()}'结果'成功'"

我的问题很简单; 为什么我不能用#{bean.gotoP1()}导航,我必须删除括号#{bean.gotoP1}?

我的代码在下面;

的index.xhtml

<h:body>    
    <h:form>
        <h:commandButton action="#{mybean.gotoP1()}" value="P1"/>
        <h:commandButton action="#{mybean.gotoP2()}" value="P2"/>
        <h:commandButton action="#{mybean.gotoP3()}" value="P3"/>
    </h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud)

mybean.java

@ManagedBean
@RequestScoped
public class Mybean implements Serializable{

    private static final long serialVersionUID=1L;

    public Mybean() {
    }

    public String gotoP1(){
        return "success";
    }

    public String gotoP2(){
        return "success";
    }

    public String gotoP3(){
        return "positive";
    }
}
Run Code Online (Sandbox Code Playgroud)

faces-config.xml中

<navigation-rule>
    <from-view-id>/index.xhtml</from-view-id>

    <navigation-case>
        <from-action>#{mybean.gotoP1}</from-action>
        <from-outcome>success</from-outcome>
        <to-view-id>/p1.xhtml</to-view-id>
    </navigation-case>

    <navigation-case>
        <from-action>#{mybean.gotoP2}</from-action>
        <from-outcome>success</from-outcome>
        <to-view-id>/p2.xhtml</to-view-id>
    </navigation-case>

    <navigation-case>
        <from-action>#{mybean.gotoP3}</from-action>
        <from-outcome>positive</from-outcome>
        <to-view-id>/p3.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>
Run Code Online (Sandbox Code Playgroud)

谢谢....

navigation jsf jsf-2

2
推荐指数
1
解决办法
187
查看次数

JSF:使用<error-page>和JSF1073错误处理错误

我有一个error-page指令将所有异常重定向到错误显示页面

我的web.xml:

<web-app [...]>
    [...]
    <error-page>
        <exception-type>java.lang.Exception</exception-type>
        <location>/view/error.xhtml</location>
    </error-page>
</web-app>
Run Code Online (Sandbox Code Playgroud)

它适用于几乎所有异常,但今天我注意到有时会记录JSF错误并且不处理异常(即,没有重定向到错误页面).

这是我在日志中的内容:

javax.enterprise.resource.webcontainer.jsf.context || JSF1073: javax.faces.event.AbortProcessingException caught during processing of INVOKE_APPLICATION 5 : UIComponent-ClientId=searchForm:j_idt147, Message=/view/listView.xhtml @217,7 actionListener="#{listController.nextPageClicked}": java.lang.NullPointerException
javax.enterprise.resource.webcontainer.jsf.context || /view/listView.xhtml @217,7 actionListener="#{listController.nextPageClicked}": java.lang.NullPointerException
javax.faces.event.AbortProcessingException: /view/listView.xhtml @217,7 actionListener="#{listController.nextPageClicked}": java.lang.NullPointerException
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:182)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) …
Run Code Online (Sandbox Code Playgroud)

error-handling jsf jsf-2

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

JSF 2.0在actionListener中验证失败后禁止调用操作

我有一个添加一些数据的对话框:

<p:commandButton id="save" 
    actionListener="#{adminNationalController.saveTeam}" 
    action="#{adminManageInternationalTournamentController.updateTeamList}"
    value="#{msg.save}" ajax="true"
    icon="ui-icon-check"
    onmousedown="return validateSubmit('addCombinedTeamForm', ['name'],'lang')"
    oncomplete="if (!args.validationFailed) addCombinedTeamDialog.hide()"
    process = "@form"
    update="lang, name, :manageTournament:dataList,:manageTournament:scroll, :menuForm:growl, :manageTournament:nationalTeam">

    <f:setPropertyActionListener 
        value="#{adminNationalController.newTeamBean}"
        target="#{adminManageInternationalTournamentController.newTeamBean}"/>

</p:commandButton> 
Run Code Online (Sandbox Code Playgroud)

saveTeam我尝试验证数据,但action案例验证失败.

是否可以禁止呼叫行动?

java jsf action actionlistener jsf-2

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

jsf给出方法未找到异常虽然它在那里,javax.el.MethodNotFoundException

尝试h:dataTable使用支持 bean显示 a 时出现以下异常

javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: /table.xhtml @29,36 action="#{user.editEmployee}": Method not found: com.jason.jsf.User@1df228e.editEmployee()
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
javax.faces.component.UICommand.broadcast(UICommand.java:311)
javax.faces.component.UIData.broadcast(UIData.java:912)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Run Code Online (Sandbox Code Playgroud)

当我使用这些文件执行以下代码时,因为我是 jsf 的新手并且正在学习,请帮忙做一些解释

雇员.java

 package com.jason.jsf;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "employee", eager = true)
@SessionScoped
public class Employee {

    private String Id, name;
    private boolean canEdit;

    public Employee() {
        super();
        // TODO Auto-generated constructor stub
    }

    public Employee(String id, String name) {
        super();
        Id = id;
        this.name = name;
    }

    public String …
Run Code Online (Sandbox Code Playgroud)

jsf el jsf-2

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

使用<p:commandButton>重定向

以下行应该保存一个新项目并重定向到另一个页面.到目前为止,它正确保存,但它没有重定向.没有错误或警告.

<p:commandButton id="savebutton" ajax="false" value="#{msg['addCategory.save']}" actionListener="#{addCategoryController.doSave()}" />
Run Code Online (Sandbox Code Playgroud)

代码背后:

 public String doSave(){       
    categoryAddEvent.fire(categoryProducer.getSelectedCategory());
    return Pages.LIST_CATEGORIES;
}
Run Code Online (Sandbox Code Playgroud)

正如我所说,第一行正确执行,第二行似乎没有做任何事情.我有什么想法可能做错了吗?

primefaces jsf-2

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

具有faces-redirect = true的导航规则未触发

我正在研究一个小型的webtool练习和导航规则已引起我的注意.所以我看了几个网络教程,并亲自尝试过,这对我不起作用.它不会重定向到所需的页面.

faces-config.xml(只有那个重要的部分)

    <navigation-rule>  
    <from-view-id>/kursleiter.xhtml</from-view-id>  
        <navigation-case>   
            <from-action>#{verifyCredentials.save}</from-action>
            <from-outcome>ok</from-outcome>   
            <to-view-id>/teilnehmer.xhtml?faces-redirect=true</to-view-id>  
        </navigation-case>  
</navigation-rule>
Run Code Online (Sandbox Code Playgroud)

返回值的类 <from-outcome>

public class verifyCredentials() {
    public String save(Klasse klasse, Module modul) {
    //do some other stuff
    return "ok";
    }
}
Run Code Online (Sandbox Code Playgroud)

按下此commandLink时,应该发生重定向

<p:commandLink actionListener="#{verifyCredentials.save(klasse, modul)}">#{modul.modulnummer} </p:commandLink>
Run Code Online (Sandbox Code Playgroud)

现在,这给我带来了几个问题:

  1. 我会需要补充/faces/<from-view-id>
  2. 难道我只是简单地将链接返回到我班级所需的页面?
  3. 我是否犯了任何逻辑错误,我太盲目了?

提前谢谢 - Reteras

navigation jsf

0
推荐指数
1
解决办法
3518
查看次数