我们怎样才能在博客项目中使用Jsf中的'Like'系统? [重复]

问题描述 投票:0回答:1

我在JSF做博客系统。我有一个类似Facebook的“喜欢”系统的想法。我想在这个博客中做我自己的这样的系统。我因为标签而遇到了问题。我的意思是,当用户点击“赞”按钮时,页面会刷新。我该如何解决这个问题?这是我的JSF代码:

<ui:repeat value="#{blogPost.queryPosts}" var="post">
    <div style="border:1px;border-color: #333;" >
        <li><h1>#{post.title}</h1></li>
        <li><h:outputText value="#{post.content}" escape="false" /> </li>
        <li>Like :<h:button value="Like" onclick="#{likePost.like2Post(post.id)}" title="Like" />
        </li>
        <li>reBlog</li>
        <li>Comments:</li>
    </div>
</ui:repeat>
java jsf button
1个回答
0
投票

按钮上的onclick属性是一个DHTML事件属性,用于调用客户端javascript。如果您需要提交表单。使用这样:

<h:commandButton value="Like" action="#{likePost.like2Post(post.id)}" />

要传递参数,您需要有el-api-2.2.jar和el-impl-2.2.jar。有关更多替代方案,请参阅此answer

此外

<h:button> 

用于GET请求。

<h:commandButton> and <h:commandLink> are used to generate POST requests.
© www.soinside.com 2019 - 2024. All rights reserved.