相关疑难解决方法(0)

如何将方法参数传递给getter?

我想使用一个datalist

<rich:dataList value="#{bean.itemsOnLevel}" var="item">
   <h:outputText value="#{item.value}" />
</rich:dataList>
Run Code Online (Sandbox Code Playgroud)

但我的吸气者需要一个参数

public List getItemsOnLevel(int level);
Run Code Online (Sandbox Code Playgroud)

我该如何通过关卡?

parameters jsf el

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

具有可变参数的 JSF 操作方法

如何在 JSF 中调用带有可变参数的方法?

我尝试过这样的事情:

<h:commandButton value="Send" action="#{myBean.checkPIN(someOtherBean.PIN)}" />
Run Code Online (Sandbox Code Playgroud)

然而,这不起作用。

variables methods el jsf-2

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

org.apache.el.parser.ParseException:遇到"("在第X行,第Y列.期待其中一个[...]

以下JSF片段:

<p:dataTable value="#{userbean.getAll()}" var="user">
Run Code Online (Sandbox Code Playgroud)

引发此异常:

Encountered "(" at line 1, column 18. Was expecting one of: "}" ... "." ... "[" ... ">" ... "gt" ... "<" ... "lt" ... ">=" ... "ge" ... "<=" ... "le" ... "==" ... "eq" ... "!=" ... "ne" ... "&&" ... "and" ... "||" ... "or" ... "*" ... "+" ... "-" ... "/" ... "div" ... "%" ... "mod" ... 
org.apache.el.parser.ParseException: Encountered "(" at line 1, column 18. Was expecting one of: …
Run Code Online (Sandbox Code Playgroud)

jsf el parentheses parseexception methodexpression

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

JSF:带参数的Bean方法调用

我无法使用参数进行方法调用以在JSF 2.0(MyFaces)和Tomcat 6中工作.

这是我尝试的方式:

<f:selectItems var="item" value="#{bla.someList} itemValue="#{item.value1}" itemLabel="#{item.value2}"> <f:param name="param1" value="0" /> </f:selectItems>

我无法定义这样的方法,对吗?那么为何不?

getSomeList(int a)
Run Code Online (Sandbox Code Playgroud)

所以这就是我的尝试:

getSomeList() {
Integer a = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("param1")); 
return doSomething(a);
}
Run Code Online (Sandbox Code Playgroud)

这就是我得到的:

java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:417)
Run Code Online (Sandbox Code Playgroud)

如果有人帮助我,我将非常感激.谢谢!

更新:啊,它适用于#{bla.getSomeList(0)}!

parameters jsf el javabeans

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

将参数传递给JSF操作

我正在使用GlassFish 3.1,并尝试将参数传递给commandButton操作.以下是我的代码:

beans.xml中

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd" />
Run Code Online (Sandbox Code Playgroud)

faces-config.xml中

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" />
Run Code Online (Sandbox Code Playgroud)

ManagedBean类

package actionParam;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named("bean")
@RequestScoped
public class ActionParam {

    public ActionParam() {
        super();
    }

    public String submit(int param) {
        System.out.println("Submit using value " + param);
        return null;
    }

}
Run Code Online (Sandbox Code Playgroud)

最后,

视图

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<h:head>
    <meta http-equiv="Content-Type"
        content="text/html; charset=ISO-8859-1" /> …
Run Code Online (Sandbox Code Playgroud)

jsf-2

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

如何使用EL 2.2方法表达式将动态参数传递给支持bean?

我正在尝试从我的支持bean中的JSF 2.0页面调用函数传递动态参数.只要我传递一个静态字符串,它工作正常,但是当我尝试使用动态字符串时,我总是得到一个EL解析错误.我猜它是一个语法问题,但我想不出用方法表达式做另一种方法.我知道我可以用<f:param..../>标签来做,但我不会放弃这个:)

<h:dataTable  var="urlresult" value="#{search.searchResults_sites_urls}">
    <h:column>
        <h:form>
            <h:outputText value="#{urlresult}" />
            <h:commandLink action="#{search.showUrls(#{urlresult})}" value=" x" />
        </h:form>
    </h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)

支持bean中的方法:

public void showUrls(String url) {
    //CODE
}
Run Code Online (Sandbox Code Playgroud)

这是怎么造成的,我该如何解决?

facelets el jsf-2

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

如何在Weblogic 10.3.x上利用EL 2.2功能?

我安装了Weblogic 10.3.5.我在服务器上部署了一个带有JSF 2.0和JSTL 1.2的WAR.但我也需要EL 2.2功能.我需要什么JAR?如果有人可以从头开始指导我一步一步的指导,那就太好了,因为我一直试图将这个问题设置好几个小时而没有运气.

java jsf weblogic el java-ee

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

#{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
查看次数

ui:param - 传递方法参数

我有两个 xhtml 文件,一个包含另一个。我已经知道如何将控制器和要调用的方法传递给对话框,我不确定是否可能,是将参数/对象实际传递给将被调用的方法。我尝试了类似的方法,但是 Eclipse 告诉我这部分有语法错误

actionListener="#{bean[confMethod(param1, param2)]}"

但它没有任何问题

actionListener="#{bean[confMethod]}"

文件1.xhtml:

<ui:composition>
.....
    <ui:include src="/jsf/include/dg_confirm.xhtml">
        <ui:param name="bean" value="#{myController}" />
        <ui:param name="question" value="Are you sure?" />
        <ui:param name="confMethod" value="myMethod" />
        <ui:param name="param1" value="#{otherController.param1}" />
        <ui:param name="param2" value="#{urlToFollow}" />
    </ui:include>

</ui:composition>
Run Code Online (Sandbox Code Playgroud)

和对话框

dg_confirm.xhtml

....
<p:commandButton value="Yes" oncomplete="PF('dlg_conf').hide();" actionListener="#{bean[confMethod(param1, param2)]}" ajax="false"/>
.....
Run Code Online (Sandbox Code Playgroud)

问题:是否可以在 JSF 中以某种方式传递方法的参数?

jsf el

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

如何在监听器中传递参数?

我怎样才能将一个arugument传递给听众方法?

我试过这样的:

<p:poll interval="3" listener="#{vehicleController.onPoll('12')}"
    update="vehicleDataList"/>
Run Code Online (Sandbox Code Playgroud)

<p:poll interval="3" listener="#{vehicleController.onPoll(vehicle.vehicleLicense)}"
    update="vehicleDataList"/>
Run Code Online (Sandbox Code Playgroud)

但它抛出以下异常:

javax.servlet.ServletException: /monitorVehicles/vehiclesList.xhtml
Failed to parse the expression [#{vehicleController.onPoll('12')}]
Run Code Online (Sandbox Code Playgroud)

我怎么能得到这个?

jsf arguments el listener primefaces

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