[jboss-svn-commits] JBL Code SVN: r11039 - in labs/jbossforums/branches/forums101P26/forums/src: resources/portal-forums-war/WEB-INF and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Apr 16 15:10:22 EDT 2007
Author: unibrew
Date: 2007-04-16 15:10:22 -0400 (Mon, 16 Apr 2007)
New Revision: 11039
Modified:
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml
Log:
[JBFORUMS-207] I rewrote watchForumView to ChooseForumSubscribtionTypeView.
Modified: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java 2007-04-16 18:29:31 UTC (rev 11038)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java 2007-04-16 19:10:22 UTC (rev 11039)
@@ -41,46 +41,44 @@
public class ForumWatchController extends ActionController
{
//ui data supporting the AddForumWatch widget
- private Collection allForums = null;
private int selectedForum = -1;
private int watchMode = -1;
+ private Forum forum = null;
- //ui data supporting the update/unwatch widget
- private Collection forumWatches = null;
-
// flag informing UI that notification edit mode is turned on
private boolean editMode;
-
+
+
/**
- * @return Returns the allForums.
+ * @return Returns the selectedForum.
*/
- public Collection getAllForums()
+ public int getSelectedForum()
{
- return allForums;
+ return selectedForum;
}
/**
- * @param allForums The allForums to set.
+ * @param selectedForum The selectedForum to set.
*/
- public void setAllForums(Collection allForums)
+ public void setSelectedForum(int selectedForum)
{
- this.allForums = allForums;
+ this.selectedForum = selectedForum;
}
-
+
/**
- * @return Returns the selectedForum.
+ *
*/
- public int getSelectedForum()
+ public Forum getForum()
{
- return selectedForum;
+ return this.forum;
}
/**
- * @param selectedForum The selectedForum to set.
+ *
*/
- public void setSelectedForum(int selectedForum)
+ public void setForum (Forum forum)
{
- this.selectedForum = selectedForum;
+ this.forum=forum;
}
/**
@@ -98,24 +96,8 @@
{
this.watchMode = watchMode;
}
-
- /**
- * @return Returns the forumWatches.
- */
- public Collection getForumWatches()
- {
- return forumWatches;
- }
/**
- * @param forumWatches The forumWatches to set.
- */
- public void setForumWatches(Collection forumWatches)
- {
- this.forumWatches = forumWatches;
- }
-
- /**
*
*/
public boolean isEditMode ()
@@ -131,24 +113,6 @@
this.editMode = editMode;
}
- /**
- *
- *
- */
- public boolean isWatchAvailable()
- {
- boolean isWatchAvailable = false;
- int watchCount = 0;
- if(this.forumWatches!=null)
- {
- watchCount = this.forumWatches.size();
- }
- if(watchCount>0)
- {
- isWatchAvailable = true;
- }
- return isWatchAvailable;
- }
//-------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
@@ -158,11 +122,8 @@
{
try
{
- //populate all the registered forums in the system
- this.allForums = this.getForumsModule().findForums();
-
//populate the already setup form watches
- this.reloadWatches();
+ //this.reloadWatches();
try
{
@@ -175,6 +136,29 @@
JSFUtil.handleException(e);
}
+ if (selectedForum!=-1)
+ {
+ try
+ {
+ this.forum = getForumsModule().findForumById(new Integer(this.selectedForum));
+ } catch (Exception e)
+ {
+ JSFUtil.handleException(e);
+ this.forum=null;
+ }
+ }
+
+ if (selectedForum!=-1)
+ {
+ try
+ {
+ this.forum = getForumsModule().findForumById(new Integer(selectedForum));
+ } catch (Exception e)
+ {
+ JSFUtil.handleException(e);
+ }
+ }
+
try
{
String edit = JSFUtil.getRequestParameter(Constants.EDIT_WATCH);
@@ -206,11 +190,30 @@
{
int forumId = this.selectedForum;
+ try
+ {
+ String wt = JSFUtil.getRequestParameter(Constants.p_notified_watch_type);
+ if (wt!=null && wt.trim().length()>0) {
+ watchMode = Integer.parseInt(wt);
+ } else {
+ watchMode = -1;
+ }
+ } catch (NumberFormatException e)
+ {
+ JSFUtil.handleException(e);
+ watchMode = -1;
+ }
+
+ if (forumId==-1 || watchMode==-1)
+ {
+ return null;
+ }
+
//make sure a watch for this forum is not already issued for this user
boolean isDuplicate = this.isDuplicateWatch(forumId);
if(isDuplicate)
{
- return navState;
+ return "success";
}
//get the forum that must be activated for watching
@@ -219,9 +222,7 @@
//activate the watch for the selected forum
this.getForumsModule().createWatch(PortalUtil.getPoster(),forum,this.watchMode);
-
- //refresh the watched list
- this.reloadWatches();
+ navState="success";
}
catch(Exception e)
{
@@ -261,9 +262,6 @@
if (watchId!=-1)
{
this.getForumsModule().removeWatch(this.getForumsModule().findForumWatchById(new Integer(watchId)));
-
- // refresh the watch list
- this.reloadWatches();
}
}
catch(Exception e)
@@ -313,6 +311,14 @@
}
/**
+ * When user cancels creating forum notification then this action is executed.
+ */
+ public String cancel()
+ {
+ return "cancel";
+ }
+
+ /**
*
*
*/
@@ -328,37 +334,20 @@
*/
private boolean isDuplicateWatch(int forumId)
{
- boolean isDuplicate = false;
-
- if(this.forumWatches!=null)
+ try
{
- for(Iterator itr=this.forumWatches.iterator();itr.hasNext();)
- {
- ForumWatch cour = (ForumWatch)itr.next();
- if(cour.getForum().getId().intValue()==forumId)
- {
- isDuplicate = true;
- break;
- }
- }
+ ForumWatch watch = getForumsModule().findForumWatchByUserAndForum(PortalUtil.getUser(), selectedForum);
+ return watch!=null;
+ } catch (Exception e)
+ {
+ JSFUtil.handleException(e);
}
-
- return isDuplicate;
+ return false;
}
/**
*
- *
*/
- private void reloadWatches() throws Exception
- {
- this.forumWatches = this.getForumsModule().
- findForumWatchByUser(PortalUtil.getUser());
- }
-
- /**
- *
- */
public String dummyAction()
{
return null;
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2007-04-16 18:29:31 UTC (rev 11038)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2007-04-16 19:10:22 UTC (rev 11039)
@@ -969,7 +969,7 @@
Subscribe=Subscribe
Unsubscribe=Unsubscribe
View_Information=View Information
-
+Add_Subscribtion=Add Subscribtion
Topic_delete_confirm=Delete Topics
Topic_delete_message=Do you really want to remove selected topics?
@@ -2051,6 +2051,9 @@
Unsubscribe_from_forum=UnSubscribe from forum
Subscribe_to_topic=Subscribe to topic
Unsubscribe_from_topic=Unsubscribe from topic
+Selected_topic=Selected topic
+Selected_forum=Selected forum
+Notification_type=Notification type
//
// Attachment Mod Admin Language Variables
@@ -2418,6 +2421,7 @@
EMAIL_NO_NOTIFICATION=No Notification by Email
EMAIL_LINKED_NOTIFICATION=Linked mode Email notification
EMAIL_EMBEDED_NOTIFICATION=Embeded mode Email notification
+SELECT_NOTIFICATION_TYPE=Select notification type
// BB Code variables
Message_code=Code
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2007-04-16 18:29:31 UTC (rev 11038)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2007-04-16 19:10:22 UTC (rev 11039)
@@ -522,14 +522,21 @@
<value>1</value>
</managed-property>
</managed-bean>
- <navigation-rule>
- <from-view-id>/views/watches/forumWatch.xhtml</from-view-id>
- <navigation-case>
- <from-outcome>updateWatch</from-outcome>
- <to-view-id>/views/watches/forumWatch.xhtml</to-view-id>
- </navigation-case>
+ <navigation-rule>
+ <from-view-id>/views/watches/forumWatch.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/views/forums/viewforum_body.xhtml</to-view-id>
+ </navigation-case>
</navigation-rule>
<navigation-rule>
+ <from-view-id>/views/watches/forumWatch.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>cancel</from-outcome>
+ <to-view-id>/views/forums/viewforum_body.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <navigation-rule>
<from-view-id>/views/myforums/myforums_editforums.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml 2007-04-16 18:29:31 UTC (rev 11038)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/forums/viewforum_body.xhtml 2007-04-16 19:10:22 UTC (rev 11039)
@@ -88,7 +88,8 @@
</h:commandLink>
</c:when>
<c:otherwise>
- <h:outputLink value="#{forums:outputLink(shared.links['forumWatch'],true)}">
+ <h:outputLink value="#{forums:outputLink(shared.links['forumWatch'],true)}">
+ <f:param name="f" value="${forum.forum.id}" />
<img src="#{forums:themeURL('resourceIconSubscribeURL')}"
alt="${resource.Subscribe_to_forum}"
name="subscribe"
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml 2007-04-16 18:29:31 UTC (rev 11038)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml 2007-04-16 19:10:22 UTC (rev 11039)
@@ -27,127 +27,72 @@
xmlns:c="http://java.sun.com/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
- xmlns:forums="http://www.jboss.com/products/jbossportal/forums" class="bb">
+ xmlns:forums="http://www.jboss.com/products/jbossportal/forums"
+ class="forumscontainer">
<ui:composition template="/views/common/common.xhtml">
<ui:define name="mainContent">
+
+<c:if test="#{forumWatch.anonymous==false}">
+<div class="forumsubscriptionconfirm">
+<h:form>
+
+ <h3>${resource.Subscribe_to_forum}</h3>
+ <p>${resource.Selected_forum}:</p>
+ <h4>#{forumWatch.forum.name}</h4>
+ <label>${resource.Notification_type}:</label>
+ <br />
+ <select name="notified_watch_type" id="notification">
+ <option value="-1">${resource.SELECT_NOTIFICATION_TYPE}</option>
+ <option value="2">${resource.EMAIL_NO_NOTIFICATION}</option>
+ <option value="0">${resource.EMAIL_LINKED_NOTIFICATION}</option>
+ <option value="1">${resource.EMAIL_EMBEDED_NOTIFICATION}</option>
+ </select>
+ <div class="forumformbuttonrow">
+ <ul>
+ <li>
+ <h:commandButton value="${resource.Add_Subscribtion}"
+ styleClass="buttonMed"
+ action="#{forumWatch.activateWatch}" />
+ </li>
+ <li>
+ <h:commandButton action="#{forumWatch.cancel}"
+ value="${resource.Cancel}"
+ accesskey="c"
+ tabindex="7"
+ styleClass="buttonMed" />
+ </li>
+ </ul>
+ <input type="hidden" name="f" value="${forumWatch.selectedForum}" />
+ </div>
+
+</h:form>
+</div>
+</c:if>
+
+<!-- in case of anonymous access -->
+<c:if test="#{forumWatch.anonymous==true}">
+<table width="100%" border="0" cellpadding="0" cellspacing="0" class="forumtablestyle">
+ <tr>
+ <td>
+ <table width="100%" cellspacing="0" cellpadding="1" border="0">
+ <tr>
+ <td> </td>
+ </tr>
+ <tr>
+ <td align="center">
+ <h:outputText value="${resource.Watch_Login_Requirement}"/>
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</c:if>
-<c:if test="#{forumWatch.anonymous==false}">
-<h1>${resource.Watches_Admin}</h1>
-
-<p>${resource.Watch_Forum_Info}</p>
-
-<h:form>
-
-<!-- Add Forum Watch widget -->
-<table cellspacing="1" cellpadding="4" border="0" align="center" class="forumline">
- <tr>
- <th class="thHead" colspan="2">${resource.Add_forum_watch}</th>
- </tr>
-
- <!-- display a list of all the registered forums -->
- <tr>
- <td class="row1" align="center">${resource.Forum}:</td>
- <td class="row2" align="center">
- <h:selectOneMenu value="#{forumWatch.selectedForum}">
- <f:selectItem itemLabel="" itemValue="0"/>
- <c:forEach items="#{forumWatch.allForums}" var="forumItem">
- <f:selectItem itemLabel="${forumItem.name}" itemValue="${forumItem.id}"/>
- </c:forEach>
- </h:selectOneMenu>
- </td>
- </tr>
- <!-- display a list of watch modes that the forum watch should have -->
- <tr>
- <td class="row1" align="center">${resource.Watch_mode}:</td>
- <td class="row2" align="center">
- <h:selectOneRadio value="#{forumWatch.watchMode}">
- <f:selectItem itemLabel="Linked" itemValue="0"/>
- <f:selectItem itemLabel="Emdedded" itemValue="1"/>
- </h:selectOneRadio>
- </td>
- </tr>
- <!-- button binds to activateWatch functionality -->
- <tr>
- <td class="catBottom" colspan="2" align="center">
- <h:commandButton value="${resource.Watch}" styleClass="mainoption" action="#{forumWatch.activateWatch}"/>
- </td>
- </tr>
-</table>
-
-<br/>
-
-<c:if test="#{forumWatch.watchAvailable}">
-<input type="hidden" name="w"/>
-<table cellspacing="1" cellpadding="2" border="0" align="center" class="forumline">
-<tr>
- <td class="cat">${resource.Forum}</td>
- <td class="cat">${resource.Watch_mode}</td>
- <td class="cat">${resource.Watch_action}</td>
-</tr>
-
-<c:forEach items="#{forumWatch.forumWatches}" var="watch">
-<tr>
- <!-- forum link -->
- <td class="row2" align="center">
- <span class="genmed">
- <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}" styleClass="genmed">
- <f:param name="f" value="#{watch.forum.id}"/>
- <h:outputText value="#{watch.forum.name}"/>
- </h:outputLink>
- </span>
- </td>
- <!-- mode -->
- <td class="row2" align="center">
- <span class="genmed">
- <h:selectOneRadio value="#{watch.mode}">
- <f:selectItem itemLabel="Linked" itemValue="0"/>
- <f:selectItem itemLabel="Emdedded" itemValue="1"/>
- </h:selectOneRadio>
- </span>
- </td>
- <!-- actions that can be done on this forum watch -->
- <td class="row2" align="center">
- <h:commandButton value="${resource.Unwatch}" action="#{forumWatch.deActivateWatch}" onclick="javascript:w.value='#{watch.id}';"/>
- </td>
-</tr>
-</c:forEach>
- <!-- button binds to updateWatch functionality -->
- <tr>
- <td class="catBottom" colspan="3" align="center">
- <h:commandButton value="${resource.Update}" styleClass="mainoption" action="#{forumWatch.updateWatch}"/>
- </td>
- </tr>
-</table>
-</c:if>
-
-</h:form>
-</c:if>
-
-
- <!-- in case of anonymous access -->
- <c:if test="#{forumWatch.anonymous==true}">
- <table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
- <tr>
- <td>
- <table width="100%" cellspacing="0" cellpadding="1" border="0">
- <tr>
- <td> </td>
- </tr>
- <tr>
- <td align="center">
- <h:outputText value="${resource.Watch_Login_Requirement}" styleClass="gen"/>
- </td>
- </tr>
- <tr>
- <td> </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </c:if>
-
</ui:define>
</ui:composition>
More information about the jboss-svn-commits
mailing list