目前,我正在开发一个使用 draw2d 库来绘制形状和图表的 Web 应用程序。在服务器端,我使用的是 Java(JSF)。
我可以说这个应用程序的 95% 只是纯 JavaScript。我希望能够从我的 JavaScript 内部发送 Ajax 请求,而无需使用隐藏字段,例如<f:inputText>
(可能使用 jQuery Ajax 组件?)。
我试图通过添加不同的隐藏 JFS 组件和 来解决这个问题jsf.ajax.request
,但无论出于何种原因,它们都不是很可靠,有时它们不发送 ajax 请求。
有什么建议吗?另外,关于 jQuery,我不确定如何在服务器端处理请求。
答:我最终使用了 Dave 的建议。我以前尝试使用此链接中的 jsFunction ,但出现错误。显然,问题是 ,它尚未在 Richfaces 4 中实现。但是,如果您使用 ,正如 dave 所提到的,它可以完美运行。
还有一点,这些豆子对我不起作用,就像戴夫盆栽的那样。我不得不将其更改如下:@ManagedBean(name = "jsFunctionBean") @SessionScoped public class JsFunctionBean {
/**
* Test String name
*/
private String name;
public String getName() { return this.name; }
public void setName(String name) { this.name = name; }
/**
* Test boolean
*/
private boolean test;
public boolean getTest() { return this.test; }
public void setTest(boolean test) { this.test = test; }
/**
* Action Method
*
* @return
*/
public String getActionMethod() {
return null;
}
public String actionMethod(){
this.test = true;
this.name = "Dave";
return null;
}
}
我不知道为什么会这样,但如果我删除 getActionMethod 或 actionMenthod 我会得到错误!