Develop and Download Open Source Software

Browse CVS Repository

Diff of /pal/blog/src/java/jp/sf/pal/blog/bean/BlogViewPageBean.java

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.15 by shinsuke, Tue Sep 19 21:35:10 2006 UTC revision 1.16 by tigercat, Wed Feb 6 03:53:02 2008 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright 2005-2006 The Portal Application Laboratory Team.   * Copyright 2005-2008 The Portal Application Laboratory Team.
3   *   *
4   * Licensed under the Apache License, Version 2.0 (the "License");   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.   * you may not use this file except in compliance with the License.
# Line 30  import jp.sf.pal.blog.model.BlogMessage; Line 30  import jp.sf.pal.blog.model.BlogMessage;
30  import jp.sf.pal.blog.model.BlogTrackback;  import jp.sf.pal.blog.model.BlogTrackback;
31  import jp.sf.pal.blog.util.BlogDaoUtil;  import jp.sf.pal.blog.util.BlogDaoUtil;
32  import jp.sf.pal.blog.util.BlogMessaging;  import jp.sf.pal.blog.util.BlogMessaging;
33    import jp.sf.pal.blog.util.BlogMessagingKeyToken;
34    
35  import org.apache.commons.logging.Log;  import org.apache.commons.logging.Log;
36  import org.apache.commons.logging.LogFactory;  import org.apache.commons.logging.LogFactory;
# Line 66  public class BlogViewPageBean Line 67  public class BlogViewPageBean
67          mode = BlogConstants.BLOG_LIST_VIEW;          mode = BlogConstants.BLOG_LIST_VIEW;
68    
69          Long id = null;          Long id = null;
70            BlogMessagingKeyToken keyToken = new BlogMessagingKeyToken();
71            keyToken.setPrefix(BlogConstants.BLOG_MESSAGE_ID);
72            keyToken.setOwner(new BlogViewSessionBean().getOwner());
73          try          try
74          {          {
75              id = (Long) BlogMessaging              id = (Long) BlogMessaging
76                      .receiveForView(BlogConstants.BLOG_MESSAGE_ID);                      .receiveForView(keyToken.toString());
77              if (log.isDebugEnabled())              if (log.isDebugEnabled())
78              {              {
79                  log.debug("BlogViewPageBean() -  : id=" + id);                  log.debug("BlogViewPageBean() -  : id=" + id);
# Line 96  public class BlogViewPageBean Line 100  public class BlogViewPageBean
100              log.debug("listView() - start");              log.debug("listView() - start");
101          }          }
102    
103          BlogMessaging.cancelForView(BlogConstants.BLOG_MESSAGE_ID);          BlogMessagingKeyToken keyToken = new BlogMessagingKeyToken();
104            keyToken.setPrefix(BlogConstants.BLOG_MESSAGE_ID);
105            keyToken.setOwner(getViewSession().getOwner());
106            BlogMessaging.cancelForView(keyToken.toString());
107    
108          if (log.isDebugEnabled())          if (log.isDebugEnabled())
109          {          {
# Line 119  public class BlogViewPageBean Line 126  public class BlogViewPageBean
126          BlogMessage blogMsg = (BlogMessage) blogMap.get("0");          BlogMessage blogMsg = (BlogMessage) blogMap.get("0");
127          if (blogMsg != null)          if (blogMsg != null)
128          {          {
129                BlogMessagingKeyToken keyToken = new BlogMessagingKeyToken();
130                keyToken.setPrefix(BlogConstants.BLOG_MESSAGE_ID);
131                keyToken.setOwner(getViewSession().getOwner());
132              try              try
133              {              {
134                  BlogMessaging.publishForView(BlogConstants.BLOG_MESSAGE_ID,                  BlogMessaging.publishForView(keyToken.toString(),
135                          blogMsg.getId());                          blogMsg.getId());
136              }              }
137              catch (NotSerializableException e)              catch (NotSerializableException e)
# Line 148  public class BlogViewPageBean Line 158  public class BlogViewPageBean
158      public String postComment()      public String postComment()
159      {      {
160          Long id = null;          Long id = null;
161            BlogMessagingKeyToken keyToken = new BlogMessagingKeyToken();
162            keyToken.setPrefix(BlogConstants.BLOG_MESSAGE_ID);
163            keyToken.setOwner(getViewSession().getOwner());
164          try          try
165          {          {
166              //TODO replace with request parameter. because session might be expired..              //TODO replace with request parameter. because session might be expired.
167              id = (Long) BlogMessaging              id = (Long) BlogMessaging
168                      .receiveForView(BlogConstants.BLOG_MESSAGE_ID);                      .receiveForView(keyToken.toString());
169    
170              if (id != null)              if (id != null)
171              {              {
# Line 483  public class BlogViewPageBean Line 496  public class BlogViewPageBean
496    
497          ExternalContext exContext = FacesContext.getCurrentInstance()          ExternalContext exContext = FacesContext.getCurrentInstance()
498                  .getExternalContext();                  .getExternalContext();
499          return "<script type=\"text/javascript\">"          return "\n"
500                    + "<script type=\"text/javascript\">"
501                  + "\n"                  + "\n"
502                  + "<!--"                  + "<!--"
503                  + "\n"                  + "\n"
# Line 491  public class BlogViewPageBean Line 505  public class BlogViewPageBean
505                  + exContext.encodeNamespace("redirect")                  + exContext.encodeNamespace("redirect")
506                  + "() {"                  + "() {"
507                  + "\n"                  + "\n"
508                    + "            var blogid = \"\";"
509                    + "\n"
510                  + "            var index = window.location.search.indexOf(\"?\");"                  + "            var index = window.location.search.indexOf(\"?\");"
511                  + "\n"                  + "\n"
512                  + "            if (index < window.location.search.length) {"                  + "            if (index < window.location.search.length) {"
513                  + "\n"                  + "\n"
514                  + "                var params = window.location.search.substr(index + 1).split(\"&\");"                  + "                var params = window.location.search.substr(index + 1).split(\"&\");"
515                  + "\n" + "                var i = 0;" + "\n"                  + "\n"
516                    + "                var i = 0;"
517                    + "\n"
518                  + "                for (i = 0; i < params.length; i++ ) {"                  + "                for (i = 0; i < params.length; i++ ) {"
519                  + "\n"                  + "\n"
520                  + "                    var pair = params[i].split(\"=\");"                  + "                    var pair = params[i].split(\"=\");"
521                  + "\n" + "                    if (pair[0] == \""                  + "\n"
522                    + "                    if (pair[0] == \""
523                  + exContext.encodeNamespace(BlogConstants.BLOG_REDIRECT_ID)                  + exContext.encodeNamespace(BlogConstants.BLOG_REDIRECT_ID)
524                  + "\" || pair[0] ==\"" + BlogConstants.BLOG_REDIRECT_ID                  + "\" || pair[0] ==\""
525                  + "\") {" + "\n" + "                        document.forms['"                  + BlogConstants.BLOG_REDIRECT_ID
526                  + exContext.encodeNamespace("redirectForm")                  + "\") {"
527                  + "'].elements[0].value = pair[1];" + "\n"                  + "\n"
528                    + "                        blogid = pair[1];"
529                    + "\n"
530                  + "                        document.forms['"                  + "                        document.forms['"
531                  + exContext.encodeNamespace("redirectForm") + "'].submit();"                  + exContext.encodeNamespace("redirectForm")
532                  + "\n" + "                    }" + "\n" + "                }"                  + "'].elements[0].value = blogid;"
533                  + "\n" + "            }" + "\n" + "        }" + "\n"                  + "\n"
534                  + "        " + exContext.encodeNamespace("redirect") + "();"                  + "                    }"
535                  + "\n" + "//-->" + "\n" + "</script>" + "\n";                  + "\n"
536                    + "                }"
537                    + "\n"
538                    + "            }"
539                    + "\n"
540                    + "            if (blogid != \"\") {"
541                    + "\n"
542                    + "                document.forms['"
543                    + exContext.encodeNamespace("redirectForm")
544                    + "'].submit();"
545                    + "\n"
546                    + "            }"
547                    + "\n"
548                    + "        }"
549                    + "\n"
550                    + "        "
551                    + exContext.encodeNamespace("redirect")
552                    + "();"
553                    + "\n"
554                    + "//-->"
555                    + "\n"
556                    + "</script>"
557                    + "\n";
558      }      }
559  }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26