Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AbstractFacesServlet,如何在java中实现AbstractFacesServlet.java?_Java_Jakarta Ee_Facescontext - Fatal编程技术网

AbstractFacesServlet,如何在java中实现AbstractFacesServlet.java?

AbstractFacesServlet,如何在java中实现AbstractFacesServlet.java?,java,jakarta-ee,facescontext,Java,Jakarta Ee,Facescontext,我创建了web服务,从中获取url参数,并将其设置为Object。 之后,当我想设置为facesContext时,它给了我NULL。我得到了在项目中实现AbstractFacesServlet.java类的建议,但知道怎么做吗? 这就是我使用的代码_ public class ReserRes extends ServerResource { @Post("xml") public void $post() throws Throwable { ........... .....

我创建了web服务,从中获取url参数,并将其设置为Object。 之后,当我想设置为facesContext时,它给了我NULL。我得到了在项目中实现AbstractFacesServlet.java类的建议,但知道怎么做吗? 这就是我使用的代码_

public class ReserRes extends ServerResource {

@Post("xml")
public void $post() throws Throwable {

...........
 .....
     FacesHelper.setValueBindingObject("SelectedOtaReservationBean",
             reservationBean);
    ......
    }    
并且setValueBindingObject(,)是

在这种情况下,我不会与任何.jsp或任何类型的UI交互。我正在获取参数并与对象绑定。这是错误的还是实现ws的FacesContext的任何方法

我有一个建议使用这个类。任何朋友都知道如何使用此工具实现或将对象设置为FacesContext吗


Thanx

我不明白。在请求通过facesservlet路由之后,FacesContext作为JSF生命周期的一部分进行初始化。这里的情况显然不是这样,那么为什么您认为可以使用FacesContext呢?实际上,我正在使用RESTWeb服务,并获取url格式参数。我没有干扰jsf页面。但是我们希望使用FacesContext Prallly到JSF来连接后端代码和方法。
public static final void setValueBindingObject(String expression,
        final Object value) {

    FacesContext facesContext = FacesContext.getCurrentInstance();

    if (facesContext == null)    // Always throwing NULL
        throw new NullPointerException(
                "Could not get a reference to the current Faces context");

    Application application = facesContext.getApplication();
    ValueBinding vb = application.createValueBinding(expression);
    vb.setValue(facesContext, value);

}