[jboss-svn-commits] JBL Code SVN: r17698 - in labs/jbossforums/branches/forums101P26/forums/src: main/org/jboss/portlet/forums/ui/action and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 10 20:55:38 EST 2008
Author: unibrew
Date: 2008-01-10 20:55:37 -0500 (Thu, 10 Jan 2008)
New Revision: 17698
Added:
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/converters/
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/converters/PollDurationConverter.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/LengthValidator.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/MessageLengthValidator.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/PollValidator.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/SubjectLengthValidator.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/ValidatorMessages.java
Modified:
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java
labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.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/classes/ResourceJSF_de.properties
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_fr.properties
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_it.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/topics/posting_edit_body.xhtml
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
Log:
[JBFORUMS-262] I made posting, editing posts and replying to posts bullet proof.
Modified: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -236,6 +236,20 @@
*
*
*/
+ public static void setErrorMessage(String id,String msg)
+ {
+ FacesMessage message = new FacesMessage(
+ FacesMessage.SEVERITY_ERROR,//severity
+ msg,//summary
+ msg//detail
+ );
+ FacesContext.getCurrentInstance().addMessage(id,message);
+ }
+
+ /**
+ *
+ *
+ */
public static String getMessage(String id)
{
String msg = null;
Modified: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -113,10 +113,6 @@
message.setText(this.message);
message.setSubject(this.subject);
- //perform domain level validation of information here....ui level validation should have already passed
- //whether done using javascript or JSF validators
- validateMessage(message);
-
//setup the forum and the corresponding poster
Forum forum = BaseController.getForumsModule().findForumById(new Integer(this.forumId));
Poster poster = PortalUtil.getPoster();
Modified: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -516,7 +516,7 @@
try
{
String optionIndex = ForumUtil.getParameter(Constants.p_option);
- String value = ForumUtil.getParameter("option_"+optionIndex);
+ String value = ForumUtil.getParameter("post:option_"+optionIndex);
this.options.put(optionIndex,value);
}
catch(Exception e)
Modified: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -196,10 +196,6 @@
message.setText(this.message);
message.setSubject(this.subject);
- //perform domain level validation of information here....ui level validation should have already passed
- //whether done using javascript or JSF validators
- validateMessage(message);
-
//setup the forum and the corresponding poster
Forum forum = BaseController.getForumsModule().findForumById(new Integer(this.forumId));
Topic topic = BaseController.getForumsModule().findTopicById(new Integer(topicId));
Added: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/converters/PollDurationConverter.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/converters/PollDurationConverter.java (rev 0)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/converters/PollDurationConverter.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -0,0 +1,57 @@
+package org.jboss.portlet.forums.ui.action.converters;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.jboss.portlet.forums.ui.Constants;
+import org.jboss.portlet.forums.ui.JSFUtil;
+import org.jboss.portlet.forums.ui.action.validators.ValidatorMessages;
+
+/**
+ * This is a special JSF converter for poll duration time.
+ * It's more or less String - Integer converter but with the option that empty String equals to 0.
+ *
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ *
+ */
+public class PollDurationConverter implements Converter
+{
+
+ public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException
+ {
+
+ if (value==null || value.trim().length()==0)
+ {
+ return new Integer(0);
+ }
+ else
+ {
+ try
+ {
+ int duration = Integer.parseInt(value);
+ return new Integer(duration);
+ }
+ catch (NumberFormatException e)
+ {
+ FacesMessage message = new FacesMessage();
+ message.setDetail(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME, ValidatorMessages.POLL_DURATION_MSG));
+ message.setSummary(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME, ValidatorMessages.POLL_DURATION_MSG));
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ConverterException(message);
+ }
+ }
+ }
+
+ public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException
+ {
+ if (value==null)
+ {
+ return "0";
+ }
+ return value.toString();
+ }
+
+}
Added: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/LengthValidator.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/LengthValidator.java (rev 0)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/LengthValidator.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portlet.forums.ui.action.validators;
+
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.jboss.portlet.forums.ui.Constants;
+import org.jboss.portlet.forums.ui.JSFUtil;
+
+/**
+ * Abstract class for defining validators that check length of user input in a JSF UIComponent.
+ *
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ *
+ */
+abstract class LengthValidator implements Validator
+{
+
+ public LengthValidator()
+ {
+ super();
+ }
+
+ public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
+ {
+
+ // A check whether it is post submition or preview action. If not validators are not executed.
+ FacesContext fc = FacesContext.getCurrentInstance();
+ Map reqParams = fc.getExternalContext().getRequestParameterMap();
+ if ( ! (reqParams.keySet().contains("post:Preview") || reqParams.keySet().contains("post:Submit")) )
+ {
+ return;
+ }
+
+ UIComponent formComp = component.getParent();
+ UIComponent validatedComp = getComponentToValidation(formComp);
+
+ if (validatedComp.getAttributes().get("value")==null
+ || validatedComp.getAttributes().get("value").toString().trim().length()<1)
+ {
+ FacesMessage message = new FacesMessage();
+ message.setDetail(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME, getMessage()));
+ message.setSummary(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME, getMessage()));
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ValidatorException(message);
+ }
+ }
+
+ protected abstract String getMessage ();
+
+ protected abstract UIComponent getComponentToValidation(UIComponent parentComponent);
+
+}
Added: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/MessageLengthValidator.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/MessageLengthValidator.java (rev 0)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/MessageLengthValidator.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portlet.forums.ui.action.validators;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Validator class for validating a length of user input in post message.
+ *
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ *
+ */
+public class MessageLengthValidator extends LengthValidator
+{
+
+ protected String getMessage ()
+ {
+ return ValidatorMessages.MESSAGE_LENGTH_ERROR;
+ }
+
+ protected UIComponent getComponentToValidation(UIComponent parentComponent)
+ {
+ return parentComponent.findComponent("message");
+ }
+
+}
Added: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/PollValidator.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/PollValidator.java (rev 0)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/PollValidator.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -0,0 +1,136 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portlet.forums.ui.action.validators;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.jboss.portlet.forums.ui.Constants;
+import org.jboss.portlet.forums.ui.JSFUtil;
+
+/**
+ * PollValidator is a class that implements JSF Validator interface
+ * and is used for validating a forum poll.
+ *
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ *
+ */
+public class PollValidator implements Validator
+{
+
+ public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
+ {
+
+ // A check whether it is post submition action. If not validators are not executed.
+ FacesContext fc = FacesContext.getCurrentInstance();
+ Map reqParams = fc.getExternalContext().getRequestParameterMap();
+ if (!reqParams.keySet().contains("post:Submit"))
+ {
+ return;
+ }
+
+ // Collecting all poll data from the form.
+ UIComponent formComp = component.getParent();
+ UIComponent questionComp = formComp.findComponent("question");
+ UIComponent pollDurationComp = formComp.findComponent("pollDuration");
+ List options = new ArrayList();
+ for (int i=1 ; ; i++ )
+ {
+ UIComponent temp = formComp.findComponent("option_"+Integer.toString(i));
+ if (temp!=null)
+ {
+ options.add(temp);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ // If there are no question or options provided by the user, we don't validate.
+ if ( !( (questionComp.getAttributes().get("value")!=null
+ && questionComp.getAttributes().get("value").toString().trim().length()!=0)
+ || (options.size()>0) ) )
+ {
+ return;
+ }
+
+ // Checks
+ if (options.size() > 10)
+ {
+ throwValidationException(ValidatorMessages.TOO_MANY_OPTIONS_MSG);
+ }
+ if (options.size() < 2)
+ {
+ throwValidationException(ValidatorMessages.TOO_FEW_OPTIONS_MSG);
+ }
+ if (questionComp.getAttributes().get("value")==null
+ || questionComp.getAttributes().get("value").toString().trim().length()==0)
+ {
+ throwValidationException(ValidatorMessages.EMPTY_POLL_QUESTION_MSG);
+ }
+ for (Iterator it = options.iterator(); it.hasNext();)
+ {
+ UIComponent option = (UIComponent)it.next();
+ if (option.getAttributes().get("value")==null
+ || option.getAttributes().get("value").toString().trim().length()==0)
+ {
+ throwValidationException(ValidatorMessages.EMPTY_POLL_OPTION_MSG);
+ }
+ }
+
+ int duration = 0;
+ if (pollDurationComp.getAttributes().get("value")!=null
+ && pollDurationComp.getAttributes().get("value").toString().trim().length()!=0)
+ {
+ try
+ {
+ duration = Integer.parseInt(pollDurationComp.getAttributes().get("value").toString());
+ }
+ catch (NumberFormatException e)
+ {
+ throwValidationException(ValidatorMessages.POLL_DURATION_MSG);
+ }
+ if (duration<0)
+ {
+ throwValidationException(ValidatorMessages.POLL_DURATION_MSG);
+ }
+ }
+ }
+
+ private void throwValidationException ( String exceptionMsg ) throws ValidatorException
+ {
+ FacesMessage message = new FacesMessage();
+ message.setDetail(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME, exceptionMsg));
+ message.setSummary(JSFUtil.getBundleMessage(Constants.BUNDLE_NAME, exceptionMsg));
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ throw new ValidatorException(message);
+ }
+}
Added: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/SubjectLengthValidator.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/SubjectLengthValidator.java (rev 0)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/SubjectLengthValidator.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portlet.forums.ui.action.validators;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Validator class for validating a length of user input in post subject.
+ *
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ *
+ */
+public class SubjectLengthValidator extends LengthValidator
+{
+
+ protected String getMessage()
+ {
+ return ValidatorMessages.SUBJECT_LENGTH_ERROR;
+ }
+
+ protected UIComponent getComponentToValidation(UIComponent parentComponent)
+ {
+ return parentComponent.findComponent("SubjectInputText");
+ }
+
+}
Added: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/ValidatorMessages.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/ValidatorMessages.java (rev 0)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/validators/ValidatorMessages.java 2008-01-11 01:55:37 UTC (rev 17698)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portlet.forums.ui.action.validators;
+
+/**
+ * This class contains constants with message bundle keys that contain error messages.
+ *
+ * @author <a href="ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
+ *
+ */
+final public class ValidatorMessages
+{
+
+ // Messages connected with input length errors.
+ public static final String SUBJECT_LENGTH_ERROR = "Empty_subject";
+ public static final String MESSAGE_LENGTH_ERROR = "Empty_message";
+
+ // Poll oriented messages.
+ public static final String EMPTY_POLL_QUESTION_MSG = "Empty_poll_title";
+ public static final String EMPTY_POLL_OPTION_MSG = "Empty_poll_option";
+ public static final String TOO_FEW_OPTIONS_MSG = "To_few_poll_options";
+ public static final String TOO_MANY_OPTIONS_MSG = "To_many_poll_options";
+ public static final String POLL_DURATION_MSG = "Wrong_poll_duration";
+
+}
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 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2008-01-11 01:55:37 UTC (rev 17698)
@@ -218,9 +218,15 @@
Post_deletion_info=This will delete the {0} post.
Topic_deletion_info=This will delete the {0} topic and the {1} messages beneath it.
Confirm_delete_poll=Are you sure you want to delete this poll?
+Empty_subject=You must specify a subject when posting a new topic.
Empty_message=You must enter a message when posting.
Forum_locked=This forum is locked: you cannot post, reply to, or edit topics.
Topic_locked=This topic is locked: you cannot edit posts or make replies.
+Empty_poll_title=You must enter a title for your poll.
+Empty_poll_option=You must enter a valid label for your poll option.
+To_few_poll_options=You must enter at least two poll options.
+To_many_poll_options=You have tried to enter too many poll options.
+Wrong_poll_duration=You must enter a valid poll duration time value.
Add_poll=Add a Poll
Add_poll_explain=If you do not want to add a poll to your topic, leave the fields blank.
Poll_question=Poll question
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_de.properties
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_de.properties 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_de.properties 2008-01-11 01:55:37 UTC (rev 17698)
@@ -218,9 +218,15 @@
Post_deletion_info=L\u00F6sche den Beitrag {0}.
Topic_deletion_info=L\u00F6sche das Thema {0} und die darin enthaltenen {1} Nachrichten.
Confirm_delete_poll=Bist du sicher, dass diese Umfrage gel\u00F6scht werden soll?
+Empty_subject=
Empty_message=Du musst zu deinem Beitrag einen Text angeben.
Forum_locked=Dieses Forum ist gesperrt: du kannst keine Themen erstellen, editieren oder beantworten.
Topic_locked=Dieses Thema ist gesperrt: du kannst keine Beitr\u00e4ge editieren oder beantworten.
+Empty_poll_title=
+Empty_poll_option=
+To_few_poll_options=
+To_many_poll_options=
+Wrong_poll_duration=
Add_poll=Umfrage hinzuf\u00fcgen
Add_poll_explain=Wenn du keine Umfrage zum Thema hinzuf\u00fcgen willst, lasse das Feld bitte leer.
Poll_question=Frage
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_fr.properties
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_fr.properties 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_fr.properties 2008-01-11 01:55:37 UTC (rev 17698)
@@ -218,9 +218,15 @@
Post_deletion_info=Cette opération effacera {0} messages.
Topic_deletion_info=Cette opération effacera {0} sujets et {1} messages qui y sont inclus.
Confirm_delete_poll=Etes-vous certain de vouloir supprimer ce sondage ?
+Empty_subject=
Empty_message=Vous devez inclure du texte au message avant de le soumettre.
Forum_locked=Ce forum est vérouillé. Vous ne pouvez y modifier les messages ou y répondre.
Topic_locked=Ce sujet est vérouillé. Vous ne pouvez y modifier les messages ou y répondre.
+Empty_poll_title=
+Empty_poll_option=
+To_few_poll_options=
+To_many_poll_options=
+Wrong_poll_duration=
Add_poll=Ajouter un sondage
Add_poll_explain=Si vous ne désirez pas créer de sondage, laissez les champs vides.
Poll_question=Question
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_it.properties
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_it.properties 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF_it.properties 2008-01-11 01:55:37 UTC (rev 17698)
@@ -96,9 +96,9 @@
L_TOPICS_PER_FORUM_EXPLAIN=Quanti topics per pagina vuoi visualizzare
L_USER_INFO=Informationi
L_MODE_HOT_TOPICS=topics rapidi (sopra alcuni numeri di repliche)
-L_MODE_HOTTEST_TOPICS=topics ancora pi\ù rapidi (pi\ù repliche)
+L_MODE_HOTTEST_TOPICS=topics ancora pi\� rapidi (pi\� repliche)
L_MODE_LATEST_POSTS=Ultimi topics inviati
-L_MODE_MOST_VIEWED=Pi\ù topics visualizzati
+L_MODE_MOST_VIEWED=Pi\� topics visualizzati
L_TOPICS_FOUND=topics trovati.
L_TOPIC_SUMMARY=Indice del topic
L_MODE_CHOOSE=Scegli la modalit\u00e0 di indice
@@ -106,7 +106,7 @@
L_TOPIC_SUMMARY_LIMIT=Limite dei topics
L_TOPIC_SUMMARY_LIMIT_EXPLAIN=Quanti topics visualizzare
L_TOPIC_SUMMARY_DAYS=Quanti vecchi posts [in giorni]
-L_TOPIC_SUMMARY_DAYS_EXPLAIN=Et\u00e0 dei posts da visualizzare nelle modalit\u00e0 "Pi\ù rapidi" e "Pi\ù visti".
+L_TOPIC_SUMMARY_DAYS_EXPLAIN=Et\u00e0 dei posts da visualizzare nelle modalit\u00e0 "Pi\� rapidi" e "Pi\� visti".
L_TOPIC_SUMMARY_REPLIES=Quante risposte in un topic
L_TOPIC_SUMMARY_REPLIES_EXPLAIN=Numero minimo di risposte nel topic per visualizzarlo in modalit\u00e0 "Rapido".
@@ -218,9 +218,15 @@
Post_deletion_info=Canceller\u00e0 il post {0}.
Topic_deletion_info=Canceller\u00e0 il topic {0} e i messaggi {1} sotto a esso.
Confirm_delete_poll=Sei sicuro di voler cancellare questa votazione?
+Empty_subject=
Empty_message=Devi inserire un messaggioquando posti.
Forum_locked=Questo forum \u00e8 bloccato: non puoi creare, rispondere o editare il topic.
Topic_locked=Questo topic \u00e8 bloccato: non puoi editare post o rispondere.
+Empty_poll_title=
+Empty_poll_option=
+To_few_poll_options=
+To_many_poll_options=
+Wrong_poll_duration=
Add_poll=Aggiungi una votazione
Add_poll_explain=Se non vuoi aggiungere una votazione al tuo topic, lascia i campi bianchi.
Poll_question=Domanda della votazione
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 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2008-01-11 01:55:37 UTC (rev 17698)
@@ -37,7 +37,27 @@
<phase-listener>org.jboss.portlet.forums.ui.event.BeginTransactionListener</phase-listener>
<phase-listener>org.jboss.portlet.forums.ui.event.EndTransactionListener</phase-listener>
</lifecycle-->
-
+
+ <!-- Custom validators definitions -->
+ <validator>
+ <validator-id>pollValidator</validator-id>
+ <validator-class>org.jboss.portlet.forums.ui.action.validators.PollValidator</validator-class>
+ </validator>
+ <validator>
+ <validator-id>messageLengthValidator</validator-id>
+ <validator-class>org.jboss.portlet.forums.ui.action.validators.MessageLengthValidator</validator-class>
+ </validator>
+ <validator>
+ <validator-id>subjectLengthValidator</validator-id>
+ <validator-class>org.jboss.portlet.forums.ui.action.validators.SubjectLengthValidator</validator-class>
+ </validator>
+
+ <!-- Custom converters definitions -->
+ <converter>
+ <converter-id>pollDurationConverter</converter-id>
+ <converter-class>org.jboss.portlet.forums.ui.action.converters.PollDurationConverter</converter-class>
+ </converter>
+
<!-- configuration for the shared EmptyController -->
<managed-bean>
<managed-bean-name>shared</managed-bean-name>
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml 2008-01-11 01:55:37 UTC (rev 17698)
@@ -286,6 +286,7 @@
<div class="forumtitletext">
<h4>${resource.Edit_Post}</h4>
+ <h:messages errorClass="failuretext" layout="table" />
</div>
<div class="PostviewStyle">
@@ -311,8 +312,8 @@
</label>
</td>
<td>
- <h:inputText value="#{editPost.subject}" maxlength="200"
- size="45" style="width: 450px;" tabindex="2"/>
+ <h:inputText value="#{editPost.subject}" maxlength="200" id="SubjectInputText"
+ size="45" style="width: 450px;" tabindex="2" />
</td>
</tr>
@@ -541,8 +542,7 @@
styleClass="Posttextarea"
onselect="storeCaret(this);"
onkeyup="storeCaret(this);"
- onclick="storeCaret(this)">
- </h:inputTextarea>
+ onclick="storeCaret(this)" />
</td>
</tr>
</tbody>
@@ -553,6 +553,12 @@
</table>
</td>
</tr>
+
+ <!-- subject and message invisible input for validator execution workaround -->
+ <h:inputHidden id="validator" value="validator">
+ <f:validator validatorId="subjectLengthValidator" />
+ <f:validator validatorId="messageLengthValidator" />
+ </h:inputHidden>
<!-- Add Options -->
<c:if test="#{editPost.firstPost}">
@@ -604,7 +610,7 @@
</label>
</td>
<td>
- <h:inputText value="#{editPost.question}" maxlength="255" style="width: 450px;"/>
+ <h:inputText value="#{editPost.question}" id="question" maxlength="255" style="width: 450px;"/>
</td>
</tr>
@@ -618,7 +624,7 @@
</label>
</td>
<td>
- <input type="text" id="option_${idx.index+1}" name="option_${idx.index+1}"
+ <h:inputText id="option_${idx.index+1}" name="option_${idx.index+1}"
value="${optionRow}" style="width: 300px;" maxlength="255"/>
 
<h:commandButton id="UpdateOption_${idx.index+1}" action="#{editPost.updateOption}" value="${resource.Update}"
@@ -637,7 +643,7 @@
</label>
</td>
<td>
- <h:inputText value="#{editPost.option}" maxlength="255" style="width: 300px;"/>
+ <h:inputText value="#{editPost.option}" id="newOption" maxlength="255" style="width: 300px;"/>
 
<h:commandButton action="#{editPost.addOption}"
value="${resource.Add_option}"
@@ -654,7 +660,9 @@
</label>
</td>
<td>
- <h:inputText value="#{editPost.activeDuration}" size="3" maxlength="3"/>
+ <h:inputText value="#{editPost.activeDuration}" id="pollDuration" size="3" maxlength="3">
+ <f:converter converterId="pollDurationConverter" />
+ </h:inputText>
 
<strong>
${resource.Days}
@@ -664,6 +672,11 @@
</td>
</tr>
+ <!-- poll invisible input for validator execution workaround -->
+ <h:inputHidden id="execute" value="execute">
+ <f:validator validatorId="pollValidator" />
+ </h:inputHidden>
+
</c:if>
</forums:isAllowed>
@@ -758,19 +771,20 @@
<ul>
<li>
<h:commandButton action="#{editPost.preview}" value="${resource.Preview}"
- onclick="return checkForm(this.parentNode)"
+ id="Preview"
styleClass="buttonMed"
tabindex="5"/>
</li>
<li>
<!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
<h:commandButton action="#{editPost.execute}" value="${resource.Submit}"
+ id="Submit"
styleClass="buttonMed"
accesskey="s" tabindex="6"/>
</li>
<li>
<h:commandButton action="#{editPost.cancel}" value="${resource.Cancel}"
- accesskey="c" tabindex="7" styleClass="buttonMed"/>
+ id="Cancel" accesskey="c" tabindex="7" styleClass="buttonMed"/>
</li>
</ul>
</div>
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2008-01-11 01:55:37 UTC (rev 17698)
@@ -286,6 +286,7 @@
<div class="forumtitletext">
<h4>${resource.Post_a_new_topic}</h4>
+ <h:messages errorClass="failuretext" layout="table" />
</div>
<div class="PostviewStyle">
@@ -310,8 +311,8 @@
</label>
</td>
<td>
- <h:inputText value="#{newTopic.subject}" maxlength="200"
- size="45" style="width: 450px;" tabindex="2"/>
+ <h:inputText value="#{newTopic.subject}" maxlength="200" id="SubjectInputText"
+ size="45" style="width: 450px;" tabindex="2" />
</td>
</tr>
@@ -540,8 +541,7 @@
styleClass="Posttextarea"
onselect="storeCaret(this);"
onkeyup="storeCaret(this);"
- onclick="storeCaret(this)">
- </h:inputTextarea>
+ onclick="storeCaret(this)" />
</td>
</tr>
</tbody>
@@ -552,7 +552,13 @@
</table>
</td>
</tr>
-
+
+ <!-- subject and message invisible input for validator execution workaround -->
+ <h:inputHidden id="validator" value="validator">
+ <f:validator validatorId="subjectLengthValidator" />
+ <f:validator validatorId="messageLengthValidator" />
+ </h:inputHidden>
+
<!-- Add Options -->
<forums:isAllowed fragment="acl://topicType" contextData="#{newTopic.forumId}">
<tr class="PostViewUnderlineBoth">
@@ -579,7 +585,8 @@
</forums:isAllowed>
<!-- poll ui -->
- <forums:isAllowed fragment="acl://managePoll">
+ <forums:isAllowed fragment="acl://managePoll">
+
<tr class="PostViewMainHeader">
<td colspan="2">
${resource.Add_poll}
@@ -599,7 +606,7 @@
</label>
</td>
<td>
- <h:inputText value="#{newTopic.question}" maxlength="255" style="width: 450px;"/>
+ <h:inputText value="#{newTopic.question}" id="question" maxlength="255" style="width: 450px;"/>
</td>
</tr>
@@ -613,7 +620,7 @@
</label>
</td>
<td>
- <input type="text" id="option_${idx.index+1}" name="option_${idx.index+1}"
+ <h:inputText id="option_${idx.index+1}" name="option_${idx.index+1}"
value="${optionRow}" style="width: 300px;" maxlength="255"/>
 
<h:commandButton id="UpdateOption_${idx.index+1}" action="#{newTopic.updateOption}" value="${resource.Update}"
@@ -632,7 +639,7 @@
</label>
</td>
<td>
- <h:inputText value="#{newTopic.option}" maxlength="255" style="width: 300px;"/>
+ <h:inputText value="#{newTopic.option}" id="newOption" maxlength="255" style="width: 300px;"/>
 
<h:commandButton action="#{newTopic.addOption}"
value="${resource.Add_option}"
@@ -649,7 +656,9 @@
</label>
</td>
<td>
- <h:inputText value="#{newTopic.activeDuration}" size="3" maxlength="3"/>
+ <h:inputText value="#{newTopic.activeDuration}" id="pollDuration" size="3" maxlength="3">
+ <f:converter converterId="pollDurationConverter" />
+ </h:inputText>
 
<strong>
${resource.Days}
@@ -657,7 +666,13 @@
 
${resource.Poll_for_explain}
</td>
- </tr>
+ </tr>
+
+ <!-- poll invisible input for validator execution workaround -->
+ <h:inputHidden id="execute" value="execute">
+ <f:validator validatorId="pollValidator" />
+ </h:inputHidden>
+
</forums:isAllowed>
<!-- attachment ui -->
@@ -750,14 +765,15 @@
<div class="forumformbuttonrow">
<ul>
<li>
- <h:commandButton action="#{newTopic.preview}" value="${resource.Preview}"
- onclick="return checkForm(this.parentNode)"
+ <h:commandButton action="#{newTopic.preview}" value="${resource.Preview}"
+ id="Preview"
styleClass="buttonMed"
tabindex="5"/>
</li>
<li>
<!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
<h:commandButton action="#{newTopic.execute}" value="${resource.Submit}"
+ id="Submit"
styleClass="buttonMed"
accesskey="s" tabindex="6">
<f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
@@ -765,7 +781,7 @@
</li>
<li>
<h:commandButton action="#{newTopic.cancel}" value="${resource.Cancel}"
- accesskey="c" tabindex="7" styleClass="buttonMed"/>
+ id="Cancel" accesskey="c" tabindex="7" styleClass="buttonMed"/>
</li>
</ul>
</div>
Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml 2008-01-10 22:46:28 UTC (rev 17697)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/posting_reply_body.xhtml 2008-01-11 01:55:37 UTC (rev 17698)
@@ -289,6 +289,7 @@
<div class="forumtitletext">
<h4>${resource.Post_a_reply}</h4>
+ <h:messages errorClass="failuretext" layout="table" />
</div>
<div class="PostviewStyle">
@@ -317,7 +318,7 @@
</label>
</td>
<td>
- <h:inputText value="#{replyTopic.subject}" maxlength="200"
+ <h:inputText value="#{replyTopic.subject}" maxlength="200" id="SubjectInputText"
size="45" style="width: 450px;" tabindex="2"/>
</td>
</tr>
@@ -547,8 +548,7 @@
styleClass="Posttextarea"
onselect="storeCaret(this);"
onkeyup="storeCaret(this);"
- onclick="storeCaret(this)">
- </h:inputTextarea>
+ onclick="storeCaret(this)" />
</td>
</tr>
</tbody>
@@ -560,6 +560,12 @@
</td>
</tr>
+ <!-- subject and message invisible input for validator execution workaround -->
+ <h:inputHidden id="validator" value="validator">
+ <f:validator validatorId="subjectLengthValidator" />
+ <f:validator validatorId="messageLengthValidator" />
+ </h:inputHidden>
+
<!-- attachment ui -->
<forums:isAllowed fragment="acl://managePostAttachments">
<tr>
@@ -651,13 +657,14 @@
<ul>
<li>
<h:commandButton action="#{replyTopic.preview}" value="${resource.Preview}"
- onclick="return checkForm(this.parentNode)"
+ id="Preview"
styleClass="buttonMed"
tabindex="5"/>
</li>
<li>
<!--TODO: Missing execution of javascript checking form - onclick="return checkForm(this.parentNode)" -->
<h:commandButton action="#{replyTopic.execute}" value="${resource.Submit}"
+ id="Submit"
styleClass="buttonMed"
accesskey="s" tabindex="6">
<f:actionListener type="org.jboss.portlet.forums.ui.event.FloodControlListener" />
@@ -665,7 +672,7 @@
</li>
<li>
<h:commandButton action="#{replyTopic.cancel}" value="${resource.Cancel}"
- accesskey="c" tabindex="7" styleClass="buttonMed"/>
+ id="Cancel" accesskey="c" tabindex="7" styleClass="buttonMed"/>
</li>
</ul>
</div>
More information about the jboss-svn-commits
mailing list