简体   繁体   English

在jsf 2应用程序中为页面添加书签

[英]bookmark a page in a jsf 2 application

I have this JSF 2 web application which retrieves a list of tweets from a database and display them as a datalist with Primefaces 我有这个JSF 2 Web应用程序,该应用程序从数据库检索推文列表,并使用Primefaces将它们显示为数据列表。

(the best is to try it to see what I mean. Go to www.tweetreference.org , click on "read a tweet reference", then input "@seinecle") (最好是尝试一下以了解我的意思。请访问www.tweetreference.org ,单击“阅读推文参考”,然后输入“ @seinecle”)

How can I make this list bookmarkable, so that one can get back to the page directly? 如何使该列表可添加书签,以便可以直接返回页面? Is it even possible? 可能吗? [I've read about GET requests and bookmarking of urls in JSF2, without success...] [我已经阅读了有关JSF2中GET请求和URL书签的信息,但没有成功...]

The source code of the page: 页面的源代码:

<?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>

Thanks! 谢谢!

You are sending the field as POST , to be bookmarkable you need to send as GET . 您以POST形式发送字段,要添加书签,您需要以GET发送。 However I read from this answer that you can redirect from POST to GET including the view params, so this might be a solution: 但是我从这个答案中得知,您可以从POST重定向到GET包括视图参数,因此这可能是一个解决方案:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM