User Registration
Perhaps the first component that comes to mind on a community site is the registration of new users. VCE is distributed with built-in features to allow template developers to write the user registration feature in minimal effort.
The struts configuration for the user registration action can be as follows:
<form-bean name="userProfileForm" type="com.ndc.usercontent.struts.actions.forms.UserProfileForm" /> <action path="/user/profile/add" name="userProfileForm" scope="request" parameter="userProfile" type="com.ndc.usercontent.struts.actions.save.SaveUserProfile"> <forward name="success" path="/?view=signupSuccess" redirect="true"/> <forward name="error" path="/index.jsp?view=signup" /> </action>
An example template that will allow a new user on the site to register his information can be as follows:
<html:form action="/user/profile/add"> <html:messages id="messages" message="true"> <bean:message name="messages"/><br/> </html:messages> <html:hidden property="articleType" value="${articleType.name}"/> <html:hidden property="homeSectionId" value="${homeSectionId}"/> <html:hidden property="state" value="${state}"/> <html:hidden property="image" value=""/> <html:hidden property="articleId"/> <html:hidden property="errorUrl" value="/signup.jsp" /> Username: <html:text property="field(username)" /><br/> Email: <html:text property="field(emailaddress)" /><br/> First name: <html:text property="field(firstname)" /><br/> Family name: <html:text property="field(surname)" /><br/> Telephone: <html:text property="field(telephone)" /><br/> <html:submit value="Register"/> </html:form>
On some community sites, you may be required to display the password of the user after registration. Set
redirect="false"
in action forwoard in struts configuration file to show the password in the forwarded page. This can
be easily achieved through the following JSP template:
<form-bean name="userProfileForm" type="com.ndc.usercontent.struts.actions.forms.UserProfileForm" /> <action path="/user/profile/add" name="userProfileForm" scope="request" parameter="userProfile" type="com.ndc.usercontent.struts.actions.save.SaveUserProfile"> <forward name="success" path="/?view=signupSuccess" redirect="false"/> <forward name="error" path="/index.jsp?view=signup" /> </action>
<logic:present name="userProfileForm"> <bean:define id="password" name="userProfileForm" property="password" type="String"/> Password: ${password}<br/> </logic:present>
The com.ndc.usercontent.struts.actions.forms.UserProfileForm
class is a subclass of the
com.ndc.usercontent.struts.actions.forms.ArticleForm
. For details on form properties
of ArticleForm
, please have a look at: Creating Articles. Apart from the
article-form properties, the user-form adds the following properties:
Form property | Description |
---|---|
|
The profile article ID of the community-user. If set, the profile identified by the ID is updated with the new information. |
|
The property is only used to display the password. See the example JSP above that renders the password. |