我正在使用JSF来构建一个站点.我在我的主页上添加了jQuery Gritter(Growl)通知.是否有可能调用内部的一个管理bean方法before_close:的$.gritter.add功能?
我想要使用的代码如下:
<h:body>
<c:forEach items="#{notificationBean.growlNotificationList}" var="p">
<script>
/* <![CDATA[ */
$.gritter.add({
// (string | mandatory) the heading of the notification
title: 'Notification',
// (string | mandatory) the text inside the notification
text: 'Comment on your staus',
// (bool | optional) if you want it to fade out on its own or just sit there
sticky: true,
// (int | optional) the time you want it to be alive for before fading out (milliseconds) …Run Code Online (Sandbox Code Playgroud) 我需要找到一种在生成文件下载后执行页面导航的方法.到目前为止,我已经准备好了文件下载和工作:
FileInputStream stream = new FileInputStream(file);
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
ec.responseReset();
ec.setResponseContentType("application/octet-stream");
ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
OutputStream out = ec.getResponseOutputStream();
byte[] outputByte = new byte[4096];
while(stream.read(outputByte, 0, 4096) != -1)
{
out.write(outputByte, 0, 4096);
}
stream.close();
out.flush();
out.close();
fc.responseComplete();
Run Code Online (Sandbox Code Playgroud)
到目前为止,我尝试从ExternalContext重定向,但我得到一个IllegalStateException.
ec.redirect(url)
Run Code Online (Sandbox Code Playgroud)
我还尝试将所有以前的代码包装在一个字符串方法中,该方法返回最后要导航的页面.那也行不通.
有什么建议?
目前,我正在开发一个使用draw2d库绘制形状和图表的Web应用程序.在服务器端我使用Java(JSF).
我可以说这个应用程序的95%只是纯JavaScript.我希望能够从我的JavaScript中发送Ajax请求,而不需要使用隐藏的字段(例如<f:inputText>使用jQuery Ajax组件?).
我试图通过添加不同的隐藏JFS组件来解决这个问题jsf.ajax.request,但是无论出于何种原因它们都不是很可靠,有时它们不会发送ajax请求.
有什么建议吗?另外,关于jQuery,我不知道如何在服务器端处理请求.
答:我最终使用了戴夫的建议.我之前尝试过使用此链接中的 jsFunction ,但是我收到了错误.显然,问题是,在Richfaces 4中尚未实现.但是,如果你使用,正如戴夫提到的那样它可以很好地工作.
还有一点,豆子对我来说不起作用,因为戴夫喝了.我必须按如下方式更改它:@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 …Run Code Online (Sandbox Code Playgroud) 我在JS代码中有一个for循环,我想调用一个方法,该方法使用JAVA托管bean编写的参数计算一个值并返回一个将在JS中使用的新注释:我在xhtml页面中使用了primefaces和handontable显示数据
这就是我的js的样子
function updateMoneyValue(){
var thetable; //the handsonTable
for (var i =0 ; i < thetable.length ; i++)
{
var myNewValue = theBeanMethod (firstParam , secondParam);
}
}
Run Code Online (Sandbox Code Playgroud) jsf ×4
javascript ×2
jquery ×2
ajax ×1
download ×1
draw2d ×1
java ×1
jsf-2 ×1
navigation ×1
primefaces ×1