You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/03/03 13:40:24 UTC
svn commit: r514141 - in /myfaces/fusion/trunk/examples: ./
src/main/java/org/apache/myfaces/examples/ballot/backings/
src/main/java/org/apache/myfaces/examples/ballot/dao/
src/main/java/org/apache/myfaces/examples/ballot/lib/
src/main/java/org/apache/...
Author: imario
Date: Sat Mar 3 04:40:23 2007
New Revision: 514141
URL: http://svn.apache.org/viewvc?view=rev&rev=514141
Log:
voting applicatoin, finished voter, started voting
Added:
myfaces/fusion/trunk/examples/NOTICE.txt
Modified:
myfaces/fusion/trunk/examples/pom.xml
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotHall.java
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoteTopic.java
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoter.java
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/dao/VoterDao.java
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/lib/BallotState.java
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/model/Voter.java
myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/FacesUtils.java
myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml
myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/web.xml
myfaces/fusion/trunk/examples/src/main/webapp/ballot/Hall.jsp
myfaces/fusion/trunk/examples/src/main/webapp/ballot/Topic.jsp
myfaces/fusion/trunk/examples/src/main/webapp/ballot/VoteTopic.jsp
myfaces/fusion/trunk/examples/src/main/webapp/ballot/Voter.jsp
myfaces/fusion/trunk/examples/src/main/webapp/default.css
Added: myfaces/fusion/trunk/examples/NOTICE.txt
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/NOTICE.txt?view=auto&rev=514141
==============================================================================
--- myfaces/fusion/trunk/examples/NOTICE.txt (added)
+++ myfaces/fusion/trunk/examples/NOTICE.txt Sat Mar 3 04:40:23 2007
@@ -0,0 +1,17 @@
+Apache MyFaces Fusion
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+As an dependency for the example application it uses:
+
+* JavaMail
+SUN Microsystems
+You can get the library and its source from http://java.sun.com/products/javamail/
+This library uses the CDDL open source license
+
+
+* TopLink Essentials
+SUN Microsystems
+You can get the library and its source from https://glassfish.dev.java.net/javaee5/persistence/
+This library uses the CDDL open source license
Modified: myfaces/fusion/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/pom.xml?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/pom.xml (original)
+++ myfaces/fusion/trunk/examples/pom.xml Sat Mar 3 04:40:23 2007
@@ -75,7 +75,11 @@
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.0.2</version>
- <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@@ -141,6 +145,7 @@
<artifactId>el-impl</artifactId>
<version>1.0</version>
</dependency>
+
</dependencies>
<build>
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotHall.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotHall.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotHall.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotHall.java Sat Mar 3 04:40:23 2007
@@ -18,14 +18,15 @@
*/
package org.apache.myfaces.examples.ballot.backings;
-import org.apache.myfaces.examples.ballot.dao.VoterDao;
+import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.examples.ballot.dao.TopicDao;
-import org.apache.myfaces.examples.ballot.model.Topic;
+import org.apache.myfaces.examples.ballot.dao.VoterDao;
import org.apache.myfaces.examples.ballot.lib.BallotState;
+import org.apache.myfaces.examples.ballot.model.Topic;
+import org.apache.myfaces.examples.ballot.model.Voter;
import org.apache.myfaces.examples.lib.FacesConst;
import org.apache.myfaces.examples.lib.FacesUtils;
-import org.apache.myfaces.fusion.conversation.ConversationManager;
-import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.fusion.conversation.ConversationUtils;
import org.springframework.transaction.annotation.Transactional;
import javax.faces.context.FacesContext;
@@ -67,13 +68,16 @@
public void initView()
{
String uuid = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("uuid");
- String mail = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("email");
- if (!StringUtils.isEmpty(uuid) && !StringUtils.isEmpty(mail))
+ String uid = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("uid");
+ if (!StringUtils.isEmpty(uuid) && !StringUtils.isEmpty(uid))
{
- if (getVoterDao().existsVoter(uuid, mail))
+ Voter voter = getVoterDao().getByKey(Long.parseLong(uid, 10));
+ if (uuid.equals(voter.getIdentification()))
{
- getBallotState().setVoterEmail(mail);
+ getBallotState().setVoterId(voter.getId());
getBallotState().setAuthenticated(true);
+
+ FacesUtils.addInfoMessage("welcome " + voter.getName());
}
else
{
@@ -137,7 +141,7 @@
{
// ensure we start with a fresh conversation on the next page
// TODO: we can avoid it once we have the flash scope
- ConversationManager.getInstance().getConversation("ballotTopic").invalidate();
+ ConversationUtils.invalidateIfExists("ballotTopic");
return FacesConst.SUCCESS;
}
@@ -145,7 +149,7 @@
{
// ensure we start with a fresh conversation on the next page
// TODO: we can avoid it once we have the flash scope
- ConversationManager.getInstance().getConversation("ballotVoteTopic").invalidate();
+ ConversationUtils.invalidateIfExists("ballotVoteTopic");
return FacesConst.SUCCESS;
}
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoteTopic.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoteTopic.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoteTopic.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoteTopic.java Sat Mar 3 04:40:23 2007
@@ -26,12 +26,13 @@
import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.examples.ballot.dao.TopicDao;
import org.apache.myfaces.examples.ballot.dao.VoteDao;
+import org.apache.myfaces.examples.ballot.lib.BallotState;
import org.apache.myfaces.examples.ballot.model.Item;
import org.apache.myfaces.examples.ballot.model.Topic;
import org.apache.myfaces.examples.ballot.model.Vote;
import org.apache.myfaces.examples.lib.FacesConst;
+import org.apache.myfaces.examples.lib.FacesUtils;
import org.apache.myfaces.fusion.conversation.Conversation;
-import org.apache.myfaces.fusion.conversation.jsf.JsfConversationUtils;
import org.springframework.transaction.annotation.Transactional;
import javax.faces.context.FacesContext;
@@ -43,6 +44,8 @@
private TopicDao topicDao;
private VoteDao voteDao;
+ private BallotState ballotState;
+
private Topic topic;
private List<ItemInfo> itemInfos;
@@ -62,6 +65,16 @@
}
}
+ public BallotState getBallotState()
+ {
+ return ballotState;
+ }
+
+ public void setBallotState(BallotState ballotState)
+ {
+ this.ballotState = ballotState;
+ }
+
public TopicDao getTopicDao()
{
return topicDao;
@@ -84,6 +97,14 @@
public void initView()
{
+ if (!getBallotState().isAuthenticated())
+ {
+ FacesUtils.addErrorMessage("you are not authenticated");
+
+ redirectToHall();
+ return;
+ }
+
if (topic == null)
{
String topicId = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("topicId");
@@ -91,11 +112,21 @@
{
initTopic(Long.valueOf(topicId, 10));
}
- else
+
+ if (getTopic() == null)
{
- JsfConversationUtils.ensureConversation("ballotVoteTopic", "ballotHall");
+ FacesUtils.addErrorMessage("not a valid topic");
+
+ redirectToHall();
+ return;
}
}
+ }
+
+ private void redirectToHall()
+ {
+ FacesContext.getCurrentInstance().getApplication().getNavigationHandler()
+ .handleNavigation(FacesContext.getCurrentInstance(), null, "ballotHall");
}
public void initTopic(Long id)
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoter.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoter.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoter.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/backings/BallotVoter.java Sat Mar 3 04:40:23 2007
@@ -25,14 +25,16 @@
import org.apache.myfaces.examples.lib.FacesUtils;
import org.apache.myfaces.examples.lib.SpringUtils;
import org.apache.myfaces.fusion.conversation.Conversation;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.transaction.PlatformTransactionManager;
import javax.faces.context.FacesContext;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import java.util.UUID;
public class BallotVoter
@@ -42,6 +44,19 @@
private VoterDao voterDao;
private Voter voter;
private BallotState ballotState;
+ private String requestEmail;
+
+ private JavaMailSender mailSender;
+
+ public JavaMailSender getMailSender()
+ {
+ return mailSender;
+ }
+
+ public void setMailSender(JavaMailSender mailSender)
+ {
+ this.mailSender = mailSender;
+ }
public PlatformTransactionManager getTransactionManager()
{
@@ -85,9 +100,9 @@
public void initView()
{
- if (getBallotState().getVoterEmail() != null)
+ if (getBallotState().getVoterId() != null)
{
- setVoter(getVoterDao().getByKey(getBallotState().getVoterEmail()));
+ setVoter(getVoterDao().getByKey(getBallotState().getVoterId()));
}
else
{
@@ -95,17 +110,32 @@
}
}
+ public String getRequestEmail()
+ {
+ return requestEmail;
+ }
+
+ public void setRequestEmail(String requestEmail)
+ {
+ this.requestEmail = requestEmail;
+ }
+
+ public boolean isNewVoter()
+ {
+ return getVoterDao().isNew(getVoter());
+ }
+
/**
* here we use programmatic transaction handling instead of declarative to allow to
* leave the mehtod without exception and without having to flush in case of an failure
*/
- public String saveAction()
+ public String saveAction() throws MessagingException
{
boolean isNew = getVoterDao().isNew(getVoter());
if (isNew)
{
- if (getVoterDao().getByKey(getVoter().getEmail()) != null)
+ if (getVoterDao().getVoterByEmail(getVoter().getEmail()) != null)
{
FacesUtils.addErrorMessage("there is already a voter with this email address registered");
return FacesConst.FAILURE;
@@ -115,19 +145,31 @@
}
getVoterDao().save(getVoter());
- getBallotState().setVoterEmail(getVoter().getEmail());
+ getBallotState().setVoterId(getVoter().getId());
SpringUtils.commit(transactionManager);
if (isNew)
{
- sendMail();
+ sendMail(getVoter().getEmail());
}
Conversation.getCurrentInstance().invalidate();
return FacesConst.SUCCESS;
}
+ public String requestCookieAction() throws MessagingException
+ {
+ if (voterDao.getVoterByEmail(getRequestEmail()) == null)
+ {
+ FacesUtils.addErrorMessage("no voter with the given e-mail address found");
+ return FacesConst.FAILURE;
+ }
+
+ sendMail(getRequestEmail());
+ return FacesConst.SUCCESS;
+ }
+
protected String createIdentification()
{
String identification;
@@ -141,10 +183,10 @@
return identification;
}
- // TODO: replace by velocity template
- protected void sendMail()
+ // XXX: in reality we should use a velocity template here
+ protected void sendMail(String email) throws MessagingException
{
- Voter voter = getVoterDao().getByKey(getBallotState().getVoterEmail());
+ Voter voter = getVoterDao().getVoterByEmail(email);
HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
@@ -160,15 +202,8 @@
}
url.append(req.getContextPath());
url.append("/ballot/Hall.faces");
- url.append("?email=");
- try
- {
- url.append(URLEncoder.encode(voter.getEmail(), "UTF-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e);
- }
+ url.append("?uid=");
+ url.append(voter.getId());
url.append("&uuid=");
url.append(voter.getIdentification());
@@ -176,7 +211,7 @@
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
- out.println("Hi!");
+ out.println("Hi " + voter.getName() + "!");
out.println("");
out.println("We are happy that your are willing to participate in the voting process.");
out.println("");
@@ -185,11 +220,17 @@
out.println(url.toString());
out.println("");
out.println("See you,");
- out.println("The Voting Machine");
+ out.println("The Voting Machine - Ballot");
out.close();
- System.err.println(sw.toString());
- // TODO: send actual mail
+ MimeMessage mimeMessage = mailSender.createMimeMessage();
+ MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage);
+ mimeMessageHelper.setSubject("Login Url For The Voting Machine");
+ mimeMessageHelper.setFrom("mario@ops.co.at");
+ mimeMessageHelper.setTo(voter.getEmail());
+ mimeMessageHelper.setText(sw.toString(), false);
+
+ mailSender.send(mimeMessage);
}
}
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/dao/VoterDao.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/dao/VoterDao.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/dao/VoterDao.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/dao/VoterDao.java Sat Mar 3 04:40:23 2007
@@ -45,9 +45,23 @@
this.entityManager = entityManager;
}
- public Voter getByKey(String email)
+ public Voter getByKey(Long id)
{
- return entityManager.find(Voter.class, email);
+ return entityManager.find(Voter.class, id);
+ }
+
+ public Voter getVoterByEmail(String email)
+ {
+ Query query = entityManager.createNamedQuery("getVoterByEmail");
+ query.setParameter("email", email);
+ try
+ {
+ return (Voter) query.getSingleResult();
+ }
+ catch (NoResultException e)
+ {
+ return null;
+ }
}
public void save(Voter voter)
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/lib/BallotState.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/lib/BallotState.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/lib/BallotState.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/lib/BallotState.java Sat Mar 3 04:40:23 2007
@@ -20,32 +20,26 @@
public class BallotState
{
- private String smtpHost;
- private String voterEmail;
+ private Long voterId;
private boolean authenticated;
- public String getSmtpHost()
+ public Long getVoterId()
{
- return smtpHost;
+ return voterId;
}
- public void setSmtpHost(String smtpHost)
+ public void setVoterId(Long voterId)
{
- this.smtpHost = smtpHost;
+ this.voterId = voterId;
}
- public String getVoterEmail()
- {
- return voterEmail;
- }
-
- public void setVoterEmail(String voterEmail)
+ public void setAuthenticated(boolean authenticated)
{
- this.voterEmail = voterEmail;
+ this.authenticated = authenticated;
}
- public void setAuthenticated(boolean authenticated)
+ public boolean isAuthenticated()
{
- this.authenticated = authenticated;
+ return authenticated;
}
}
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/model/Voter.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/model/Voter.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/model/Voter.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/ballot/model/Voter.java Sat Mar 3 04:40:23 2007
@@ -27,18 +27,31 @@
import javax.persistence.Id;
import javax.persistence.Version;
import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
-@NamedQuery(
- name="getVoterByIdentification",
- query="select voter from Voter voter where voter.identification = :identification"
-)
+@NamedQueries(
+ value = {
+ @NamedQuery(
+ name = "getVoterByIdentification",
+ query = "select voter from Voter voter where voter.identification = :identification"),
+ @NamedQuery(
+ name = "getVoterByEmail",
+ query = "select voter from Voter voter where voter.email = :email")
+ })
@Entity
public class Voter
{
@Id
+ @GeneratedValue(strategy= GenerationType.SEQUENCE)
+ private Long id;
+
+ @Column(nullable = false)
private String email;
+ @Column(nullable = false)
private String name;
@Column(nullable = false)
@@ -47,6 +60,15 @@
@Version
private Long version;
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
public String getName()
{
Modified: myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/FacesUtils.java?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/FacesUtils.java (original)
+++ myfaces/fusion/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/FacesUtils.java Sat Mar 3 04:40:23 2007
@@ -33,4 +33,10 @@
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
}
+
+ public static void addInfoMessage(String message)
+ {
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
+ }
}
Modified: myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml Sat Mar 3 04:40:23 2007
@@ -109,6 +109,12 @@
</bean>
-->
+ <!-- system stuff -->
+
+ <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
+ <property name="host" value="smtp"/>
+ </bean>
+
<!-- dao -->
<bean
name="componentDao"
@@ -159,13 +165,15 @@
name="voterDao"
class="org.apache.myfaces.examples.ballot.dao.VoterDao">
</bean>
+ <bean
+ name="voteDao"
+ class="org.apache.myfaces.examples.ballot.dao.VoteDao">
+ </bean>
<bean
name="ballotState"
class="org.apache.myfaces.examples.ballot.lib.BallotState"
scope="session">
-
- <property name="smtpHost" value="smtp.int.ops.co.at" />
</bean>
Modified: myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml Sat Mar 3 04:40:23 2007
@@ -22,6 +22,7 @@
<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
+ <navigation-handler>org.apache.myfaces.custom.redirectTracker.RedirectTrackerNavigationHandler</navigation-handler>
<navigation-handler>org.apache.myfaces.fusion.urlParamNav.UrlParameterNavigationHandler</navigation-handler>
<view-handler>org.apache.myfaces.fusion.urlParamNav.UrlParameterViewHandler</view-handler>
</application>
@@ -92,6 +93,16 @@
<from-action>#{ballotHall.voteAction}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/ballot/VoteTopic.jsp?topicId=#{param.topicId}</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <description>vote on topic</description>
+ <navigation-case>
+ <from-action>#{ballotVoter.saveAction}</from-action>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/ballot/Hall.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
Modified: myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/web.xml?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/WEB-INF/web.xml Sat Mar 3 04:40:23 2007
@@ -70,6 +70,11 @@
<param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>
</context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.redirectTracker.POLICY</param-name>
+ <param-value>org.apache.myfaces.custom.redirectTracker.policy.MessagesRedirectTrackPolicy</param-value>
+ </context-param>
+
<filter>
<filter-name>FacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
Modified: myfaces/fusion/trunk/examples/src/main/webapp/ballot/Hall.jsp
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/ballot/Hall.jsp?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/ballot/Hall.jsp (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/ballot/Hall.jsp Sat Mar 3 04:40:23 2007
@@ -36,23 +36,26 @@
<h:commandLink
value="Register"
action="registerVoter"
- rendered="#{ballotState.voterEmail == null}"/>
+ rendered="#{!ballotState.authenticated}"/>
<h:commandLink
value="Edit Voter Data"
action="registerVoter"
- rendered="#{ballotState.voterEmail != null}"/>
+ rendered="#{ballotState.authenticated}"/>
</h:panelGrid>
<t:dataTable
var="topicInfo"
value="#{ballotHall.topics}"
rowClasses="TR1,TR2"
- width="60%">
+ width="95%">
<f:facet name="footer">
<h:panelGroup>
- <h:commandButton value="Create new topic" action="#{ballotHall.newTopicAction}" />
+ <h:commandButton
+ value="Create new topic"
+ action="#{ballotHall.newTopicAction}"
+ rendered="#{ballotState.authenticated}"/>
</h:panelGroup>
</f:facet>
@@ -90,7 +93,7 @@
</f:facet>
<h:commandLink
- value="Show items"
+ value="Show details"
action="#{ballotHall.showItemsAction}"
rendered="#{!topicInfo.topic.started}">
Modified: myfaces/fusion/trunk/examples/src/main/webapp/ballot/Topic.jsp
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/ballot/Topic.jsp?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/ballot/Topic.jsp (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/ballot/Topic.jsp Sat Mar 3 04:40:23 2007
@@ -32,6 +32,10 @@
<h:outputText value="Ballot Topic"/>
</t:htmlTag>
+ <s:subForm>
+ <h:commandLink action="ballotHall" value="Back to Hall" />
+ </s:subForm>
+
<h:panelGrid
columns="1"
width="100%">
@@ -41,12 +45,13 @@
<h:commandButton
value="Cancel & New"
- action="#{ballotTopic.newAction}"/>
+ action="#{ballotTopic.newAction}"
+ rendered="#{ballotState.authenticated}"/>
<h:commandButton
value="Save"
action="#{ballotTopic.saveAction}"
- rendered="#{!ballotTopic.topic.started}"/>
+ rendered="#{!ballotTopic.topic.started && ballotState.authenticated}"/>
</h:panelGrid>
</f:facet>
@@ -69,10 +74,10 @@
value="#{ballotTopic.topic.name}"
size="80"
maxlength="200"
- rendered="#{!ballotTopic.topic.started}"/>
+ rendered="#{!ballotTopic.topic.started && ballotState.authenticated}"/>
<h:outputText
value="#{ballotTopic.topic.name}"
- rendered="#{ballotTopic.topic.started}"/>
+ rendered="#{ballotTopic.topic.started || !ballotState.authenticated}"/>
<h:outputLabel
for="description"
@@ -80,14 +85,15 @@
<h:inputTextarea
id="description"
value="#{ballotTopic.topic.description}"
- cols="40"
- rendered="#{!ballotTopic.topic.started}">
+ cols="80"
+ rows="8"
+ rendered="#{!ballotTopic.topic.started && ballotState.authenticated}">
<f:validateLength maximum="1024" />
</h:inputTextarea>
<h:outputText
value="#{ballotTopic.topic.description}"
- rendered="#{ballotTopic.topic.started}"/>
+ rendered="#{ballotTopic.topic.started || !ballotState.authenticated}"/>
<h:outputLabel
for="started"
@@ -95,7 +101,7 @@
<h:selectBooleanCheckbox
id="started"
value="#{ballotTopic.topic.started}"
- readonly="#{ballotTopic.topic.started}" />
+ readonly="#{ballotTopic.topic.started || !ballotState.authenticated}" />
</h:panelGrid>
@@ -126,7 +132,7 @@
<h:commandLink
value="Remove item"
action="#{ballotTopic.removeItemAction}"
- rendered="#{!ballotTopic.topic.started}">
+ rendered="#{!ballotTopic.topic.started && ballotState.authenticated}">
<t:updateActionListener property="#{ballotTopic.selectedItem}" value="#{item}" />
@@ -136,7 +142,7 @@
</t:dataTable>
<h:panelGroup
- rendered="#{!ballotTopic.topic.started}">
+ rendered="#{!ballotTopic.topic.started && ballotState.authenticated}">
<s:subForm>
<h:inputText
value="#{ballotTopic.newItem.content}"
Modified: myfaces/fusion/trunk/examples/src/main/webapp/ballot/VoteTopic.jsp
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/ballot/VoteTopic.jsp?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/ballot/VoteTopic.jsp (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/ballot/VoteTopic.jsp Sat Mar 3 04:40:23 2007
@@ -29,9 +29,13 @@
<h:form>
<t:htmlTag value="h3">
- <h:outputText value="Ballot Vote on Topic"/>
+ <h:outputText value="Ballot - Vote on Topic"/>
</t:htmlTag>
+ <s:subForm>
+ <h:commandLink action="ballotHall" value="Back to Hall" />
+ </s:subForm>
+
<h:panelGrid
columns="1"
width="100%">
@@ -66,14 +70,6 @@
<h:outputText
value="#{ballotVoteTopic.topic.description}"/>
- <h:outputLabel
- for="started"
- value="Started"/>
- <h:selectBooleanCheckbox
- id="started"
- value="#{ballotVoteTopic.topic.started}"
- readonly="true" />
-
</h:panelGrid>
<t:dataTable
@@ -92,7 +88,7 @@
<f:facet name="header">
<h:outputText value="content"/>
</f:facet>
- <h:outputText value="#{itemInfo.ite.content}"/>
+ <h:outputText value="#{itemInfo.item.content}"/>
</t:column>
<h:column>
@@ -100,9 +96,11 @@
<h:outputText value="Vote"/>
</f:facet>
+<%--
<h:selectOneRadio value="#{item.vote}">
</h:selectOneRadio>
+--%>
</h:column>
</t:dataTable>
Modified: myfaces/fusion/trunk/examples/src/main/webapp/ballot/Voter.jsp
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/ballot/Voter.jsp?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/ballot/Voter.jsp (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/ballot/Voter.jsp Sat Mar 3 04:40:23 2007
@@ -24,57 +24,98 @@
<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s" %>
<f:view>
-<%@include file="../header.jspf"%>
+ <%@ include file="../header.jspf" %>
-<h:form>
+ <h:form>
- <t:htmlTag value="h3">
- <h:outputText value="Ballot - Voter" />
- </t:htmlTag>
-
- <h:panelGrid
- columns="2"
- columnClasses="TR1,TR2"
- styleClass="inputTable"
- width="40%">
-
- <f:facet name="header">
- <h:outputText value="Voter" />
- </f:facet>
- <f:facet name="footer">
+ <t:htmlTag value="h3">
+ <h:outputText value="Ballot - Voter"/>
+ </t:htmlTag>
+
+ <s:subForm>
+ <h:commandLink action="ballotHall" value="Back to Hall" />
+ </s:subForm>
+
+ <s:subForm>
<h:panelGrid
- columns="1"
+ columns="2"
+ rowClasses="TR1,TR2"
+ styleClass="inputTable"
width="40%">
- <h:commandButton
- action="#{ballotVoter.saveAction}"
- value="Save" />
- <h:outputText value="If you are a new voter you'll receive your login url on the provided email address" />
- </h:panelGrid>
- </f:facet>
+ <f:facet name="header">
+ <h:outputText value="Register New / Edit data"/>
+ </f:facet>
+ <f:facet name="footer">
+
+ <h:commandButton
+ action="#{ballotVoter.saveAction}"
+ value="Save"/>
+
+ </f:facet>
+
+
+ <h:outputLabel
+ for="email"
+ value="E-Mail"/>
+ <h:inputText
+ id="email"
+ value="#{ballotVoter.voter.email}"
+ required="true"
+ size="40"
+ maxlength="200"
+ rendered="#{ballotVoter.newVoter}"/>
+ <h:outputText
+ value="#{ballotVoter.voter.email}"
+ rendered="#{!ballotVoter.newVoter}"/>
+
+ <h:outputLabel
+ for="name"
+ value="Name"/>
+ <h:inputText
+ id="name"
+ value="#{ballotVoter.voter.name}"
+ required="true"
+ size="80"
+ maxlength="200"/>
+
+ </h:panelGrid>
+ </s:subForm>
- <h:outputLabel
- for="email"
- value="E-Mail" />
- <h:inputText
- id="email"
- value="#{ballotVoter.voter.email}"
- required="true"
- size="40"
- maxlength="200"/>
-
- <h:outputLabel
- for="name"
- value="Name" />
- <h:inputText
- id="name"
- value="#{ballotVoter.voter.name}"
- required="true"
- size="80"
- maxlength="200"/>
+ <h:outputText
+ value="If you are a new voter you'll receive your login url on the provided email address. You have to use this url to being able to vote."/>
+
+ <s:subForm>
+ <h:panelGrid
+ columns="2"
+ rowClasses="TR1,TR2"
+ styleClass="inputTable"
+ width="40%">
+ <f:facet name="header">
+ <h:outputText value="Lost Login Url"/>
+ </f:facet>
+ <f:facet name="footer">
+
+ <h:commandButton
+ action="#{ballotVoter.requestCookieAction}"
+ value="Request login url"/>
+
+ </f:facet>
+
+ <h:outputLabel
+ for="email"
+ value="E-Mail"/>
+ <h:inputText
+ id="email"
+ value="#{ballotVoter.requestEmail}"
+ required="true"
+ size="40"
+ maxlength="200"/>
- </h:panelGrid>
-</h:form>
+ </h:panelGrid>
+ </s:subForm>
+
+ </h:form>
-<%@include file="../footer.jspf"%>
+ <%@ include file="../footer.jspf" %>
</f:view>
Modified: myfaces/fusion/trunk/examples/src/main/webapp/default.css
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/examples/src/main/webapp/default.css?view=diff&rev=514141&r1=514140&r2=514141
==============================================================================
--- myfaces/fusion/trunk/examples/src/main/webapp/default.css (original)
+++ myfaces/fusion/trunk/examples/src/main/webapp/default.css Sat Mar 3 04:40:23 2007
@@ -59,12 +59,12 @@
.TR1
{
- background-color: #ffff99;
+ background-color: #ffffdd;
}
.TR2
{
- background-color: #cccccc;
+ background-color: #eeeeee;
}
.fixtext
@@ -82,7 +82,7 @@
input, textarea, select, button
{
border-width: 1px;
- border-color: #cccccc;
+ border-color: #bbbbbb;
border-style: solid;
}