[opencms-dev] Alkacon userRegistration : case if user already exists
Sandrine Prousteau
s.prousteau at eurelis.com
Mon Jan 18 14:36:25 CET 2010
Hi,
I'm trying to customize error message in case the username named
asked in registration form already exists. But it seems this case is not
tested with the 'showform'. It would be great that in this case, a
special message occurs and the form is still shown...
Or perphaps my templates miss something...
I'm on OpenCms7.5.1 with
com.alkacon.opencms.registration_0.9.zip.
This is my code:
<code>
if
(org.opencms.util.CmsStringUtil.isNotEmptyOrWhitespaceOnly(actcode)) {
request.setAttribute("formhandler",
cmsRegistrationFormHandler);%>
<c:if test="${!empty
uri_template_activation}"><cms:include page="${uri_template_activation}"
/></c:if>
<% }
else {
boolean showForm =
cmsRegistrationFormHandler.showForm();
if (! showForm) {
if
(cmsRegistrationFormHandler.showCheck()) {
request.setAttribute("formhandler", cmsRegistrationFormHandler);%>
<c:if test="${!empty
uri_template_check}"><cms:include page="${uri_template_check}" /></c:if>
<% }else{
if
(cmsRegistrationFormHandler.sendData()) {
request.setAttribute("formhandler", cmsRegistrationFormHandler);%>
<c:if
test="${!empty uri_template_confirmation}"><cms:include
page="${uri_template_confirmation}" /></c:if>
<% }else{
//ERROR APPEARS
HERE!!!!!
Iterator it_errors
= cmsRegistrationFormHandler.getErrors().keySet().iterator();
while(it_errors.hasNext()){
String
errorkey = (String)it_errors.next();%>
<p
class="error_message"><%=cmsRegistrationFormHandler.getErrors().get(erro
rkey)%></p>
<% }
}
}
}else {
CmsForm formConfiguration =
cmsRegistrationFormHandler.getFormConfiguration();
List fields =
formConfiguration.getFields();%>
<div class="form_text">
<%=formConfiguration.getFormText()%>
</div>
<% if
(cmsRegistrationFormHandler.hasValidationErrors()) {%>
<p
class="error_message"><eurelis:getProperty key="form.error.message"
/></p>
<% }%>
<form name="alkaconregform"
id="alkaconregform" class="form"
action="<cms:link><%=cmsRegistrationFormHandler.getRequestContext().getU
ri()%></cms:link>" method="post" enctype="multipart/form-data" >
<input type="hidden"
name="<%=CmsFormHandler.PARAM_FORMACTION%>"
id="<%=CmsFormHandler.PARAM_FORMACTION%>"
value="<%=CmsFormHandler.ACTION_SUBMIT%>"/>
<table
class="request_table" cellspacing="0">
<%=
formConfiguration.getFormAttributes() %>
<% int pos=0;
int place=0;
for( int i =
0, n = fields.size(); i < n; i++) {
// loop
through all form input fields
I_CmsField field = (I_CmsField)fields.get(i);
if(i==n-1)place=1; //the last one must close the tr
field.setPlaceholder(place);
field.setPosition(pos);
String
errorMessage =
(String)cmsRegistrationFormHandler.getErrors().get(field.getName());
out.println(field.buildHtml(cmsRegistrationFormHandler, messages,
errorMessage, formConfiguration.isShowMandatory()));
pos=field.getPosition();
place=field.getPlaceholder();
}%>
<% if
(formConfiguration.hasMandatoryFields() &&
formConfiguration.isShowMandatory()) { %>
<tr
class="line_mandatory_message">
<td
colspan="2"><eurelis:getProperty key="form.message.mandatory" /></td>
</tr>
<% }%>
<tr
class="line_submit_buttons">
<td
colspan="2">
<input
type="submit" value="<eurelis:getProperty key="form.button.submit" />"
class="formbutton submitbutton"/>
<% if
(formConfiguration.isShowReset()) { %>
<input
type="reset" value="<eurelis:getProperty key="form.button.reset" />"
class="formbutton resetbutton"/>
<% } %>
</td>
</tr>
</table>
</form>
<% }//fin showForm
}//fin actcode vide
}//fin !loggedIn
else{%>
<p
class="error_message"><eurelis:getProperty
key="registration.form.logged" /></p>
<% }
</code>
If you have some ideas to get this error message customizable...
Cordially,
S. Prousteau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100118/2576f5a6/attachment.htm>
More information about the opencms-dev
mailing list