JSF 2.0,Mojarra 2.0.1,PrimeFaces 3.4.1
这是一个p:inputText组件,当按下回车键时,它应该调用一个支持bean方法.
<p:inputText id="commentInput" rendered="#{status.haveComment}"
value="#{statusBean.newComment}"
onkeypress="if (event.keyCode == 13) { onchange(); return false; }">
<f:ajax event="change" listener="#{statusBean.test}" />
</p:inputText>
Run Code Online (Sandbox Code Playgroud)
虽然支持bean有以下方法:
public void test(AjaxBehaviorEvent event) {
System.out.println("Pressed enter!");
}
Run Code Online (Sandbox Code Playgroud)
当按下回车键时它是调用方法,但它有更多; 意外行为案例:
--Click input text
----Type some letters
------Click somewhere else in the page
--------CONSOLE: Pressed enter!
Run Code Online (Sandbox Code Playgroud)
我认为ajax event=change以某种方式检测到变化并调用该方法.如何将此p:inputText组件转换为适当的评论接受者组件,如Facebook或其他人?
JSF 2.0,Mojarra 2.0.1,PrimeFaces 3.4.1
有类似的问题,但我需要...... 其他; javascript函数必须等待支持bean方法,它正在填充想要从js函数中提取的变量.我想说的是:
<p:commandLink action="#{statusBean.getStatuses}" oncomplete="afterLoad()"/>
Run Code Online (Sandbox Code Playgroud)
假设js只是获取值并将其打印到屏幕上.
function afterLoad() {
alert("#{statusBean.size}");
}
Run Code Online (Sandbox Code Playgroud)
这是生日小子:
@ManagedBean
@ViewScoped
public class StatusBean {
public int size=0;
List<Status> panelList = new ArrayList<Status>();
public void getStatuses() {
this.panelList = fillList();
this.size = panelList.size(); //Assuming 3
}
//getter and setters
}
Run Code Online (Sandbox Code Playgroud)
因此函数将大小警告为0,这是它的初始值,而我们期望看到3.
它是如何工作的:如果我将@PostConstruct注释添加到bean的头部肯定会得到正确的大小,因为bean已经在页面加载之前构造.但这意味着冗余进程,在commandlink操作之后只需要值.那么如何推迟js功能呢?有任何想法吗?
RackSpace云服务器Ubuntu-12.04,Intellij Idea-11.1.2,Windows-8,Tomcat-7.0.26,JDK-6.
在Intellij Idea上,当我尝试在我的远程Tomcat 7服务器上运行jsf项目时,它说:
运行servername时出错:无法连接到ip-address:1099
似乎问题是关于JNDI端口是1099但是我想不能激活它.某事Tomcat配置是...... 像那样:

我试过了什么?
使用以下命令在服务器端设置CATALINA_OPTS或JAVA_OPTS:
CATALINA_OPTS=-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Run Code Online (Sandbox Code Playgroud)
和
JAVA_OPTS=-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Run Code Online (Sandbox Code Playgroud)
但是这个没有用,有什么想法吗?
我已经尝试为具有p:poll视图层的基本社交网络和一个简单的NotificationService类实现基本通知系统,该类从DB获取新通知并刷新通知列表,NotificationBean其中每个用户都是视图编组.与此类似的流程:
-Poll calls NotificationBean.getNewNotifications for example every 15 sec.
--getNewNotifications calls NotificationService and DAO methods
---notificationList of user is refreshed
----DataTable on view layer shows new notifications
Run Code Online (Sandbox Code Playgroud)
但关注的p:poll是它的性能,因为它在每个间隔到期时发送一个查询.
PrimeFaces有PrimePush,基于Atmosphere Framework,它打开网络套接字,似乎更适合创建通知系统.
但我不知道应该使用哪些组件和属性.它有属性的p:socket组件channel.我应该使用用户名作为channel值吗?以下来自PrimeFaces的代码展示并总结了最后的句子:
<p:socket onMessage="handleMessage" channel="/notifications" />
Run Code Online (Sandbox Code Playgroud)
据我所知,从这个展示示例中,这会p:socket监听notifications频道.推送代码片段是:
PushContext pushContext = PushContextFactory.getDefault().getPushContext();
pushContext.push("/notifications", new FacesMessage(summary, detail));
Run Code Online (Sandbox Code Playgroud)
但这会通知所有用户页面,我需要一个通知特定用户的推送器.假设有2个用户并假设User1将User2添加为朋友.必须有某事.像那样:
pushContext.push("User2/notifications", new FacesMessage("friendship request", "from User1"));
Run Code Online (Sandbox Code Playgroud)
但我不确定这是否是这种功能要求的正确用法.考虑到应用程序的可扩展性,每个进程打开如此多的通道可能会产生昂贵的成本.
谢谢你的帮助.
我试图在使用dotdotdot插件的面板中显示评论列表,但结果并不欢呼:

从下面的xhtml代码:
<li>
<h:link value="#{Comment.commentAuthorName}: " id="goToProfileWithAuthorName"
outcome="/profile.xhtml" type="submit"
style="text-decoration:none;font-weight:bold;font-size: 11px;color: rgb(120,120,159);">
<f:param name="userId" value="#{Comment.comauthorId}"/>
</h:link>
<div id="wrapper">
#{Comment.commentText}
</div>
<br></br>
<abbr class="timeago" title="#{Comment.commentDate}"
style="color: #778899;font-size: 10px;">
</abbr>
<br/>
</li>
Run Code Online (Sandbox Code Playgroud)
并在js代码下面:
$(document).ready(function() {
$("#wrapper").dotdotdot({
// configuration goes here
});
})
Run Code Online (Sandbox Code Playgroud)
如果我解决了溢出的问题,我可以解决垂直尺寸问题,但我想猜测dotdotdot是不正确的.让我再向你展示一个奇怪的事情:

正如您所看到的,似乎div(包装器)宽度值正确计算但文本仍然溢出.可能是什么原因?
谢谢你的帮助.
JSF 2.0的ui:repeat标签获取java bean(arraylist)的值,因为它是value属性但size属性没有.我在数据表中使用ui repeat,迭代显示状态,ui repeat显示每个状态的注释.我从java类中给出了ui repeat的size属性,因为每个状态都有不同数量的注释.因此,应该动态决定大小.以下是我所做的总结.型号类:
@ManagedBean
@RequestScoped
public class Comment {
private String commentAuthorName;
//getter and setter
}
Run Code Online (Sandbox Code Playgroud)
这表示Status类,其中包含注释列表:
@ManagedBean
@RequestScoped
public class Status {
private ArrayList<Comment> commentList;
private int numOfComments;
//getter and setter
}
Run Code Online (Sandbox Code Playgroud)
这是关于StatusBean类的一个想法:
@ManagedBean
@SessionScoped
public class StatusBean {
List<Status> panelList = new ArrayList<Status>();
List<Comment> commentList = new ArrayList<Comment>();
public static void process() {
panelList = StatusService.getPersonalStatus(log.getLoggeduser());//means fill list
commentList = StatusService.getPersonalComments(panelList);//gets comments via related statuses
for (int i=0; i<panelList.size(); i++) { //for each status
Status …Run Code Online (Sandbox Code Playgroud) jsf-2 ×4
jsf ×3
primefaces ×3
javascript ×2
css ×1
datatable ×1
deployment ×1
dotdotdot ×1
jquery ×1
linux ×1
tomcat ×1
uirepeat ×1
xhtml ×1