【问题标题】:bookmark a page in a jsf 2 application在 jsf 2 应用程序中为页面添加书签
【发布时间】:2012-12-02 10:45:05
【问题描述】:

我有这个 JSF 2 Web 应用程序,它从数据库中检索推文列表并将它们显示为带有 Primefaces 的数据列表

(最好是试试看我的意思。转到www.tweetreference.org,点击“阅读推文参考”,然后输入“@seinecle”)

我怎样才能使这个列表成为书签,以便人们可以直接返回页面?甚至可能吗? [我读过 JSF2 中的 GET 请求和 url 书签,但没有成功...]

页面源代码:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>TweetReference</title>
        <h:outputStylesheet library="css" name="index.css" />
    </h:head>
    <h:body>    

        <h:link value="back to the home page" outcome="index.xhtml" />

        <div id="box">
            <div id="text">
                <div id="title">Tweet references for #{controllerBean.searchTerm}:</div>
                <div class="datalist-noborder">
                    <p:dataList value="#{searchResultsBean.references}" var="ref" itemType="none">  
                        <br></br>
                        <br></br>
                        <br></br>
                        <span style="float: left;"><img src="#{ref.author.pic_url}" width="85"></img></span>
                        <span style="font-size: 12px;padding-left: 10px;">
                            <b>#{ref.author.realName} (@#{ref.author.screenName})</b></span>
                        <br></br>
                        <span style="font-size: 12px;padding-left: 10px;">#{ref.author.description}</span>
                        <br></br>
                        <span style="font-size: 12px;padding-left: 10px;"><b>#{ref.author.location}</b></span>
                        <br></br>
                        <span style="font-size: 12px;padding-left: 10px;">[#{ref.author.followersCount} followers on Twitter].</span>
                        <br></br>
                        <br></br>
                        said in #{ref.monthYear}:
                        <span style="font-size: 40px;">&ldquo;</span>#{ref.text}<span style="font-size: 40px;">&rdquo;</span>  
                    </p:dataList>  
                </div>
            </div>
        </div>

    </h:body>
</html>

谢谢!

【问题讨论】:

  • 是的,我想是的。你能说得更直白一点吗?

标签: java jsf rest get bookmarks


【解决方案1】:

您将字段发送为POST,要成为书签,您需要发送为GET。但是我从this answer 读到,您可以从POST 重定向到GET,包括视图参数,所以这可能是一个解决方案:

<h:commandButton value="Submit" action="form?faces-redirect=true&amp;includeViewParams=true"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 2019-08-18
    • 1970-01-01
    • 2012-08-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多