Hi,
Well i am at a critical stage in my project. i am hacking the webgui of
cosmo and hence trying to add one more field in Sign up form "alternate
Email". Now the component has been added.
the .js file where i have changed are
1. Add fields in common.js adding the following code
****************************************
f = { label: _('Signup.Form.AlternateMail'),
elemName: 'alternateEmail',
elemType: 'text'
};
f.validators = function (elem) {
return cosmo.util.validate.required(elem); };
f.value = a[f.elemName];
list.push(f);
*****************************************
2. change The label keys in properties file
3. change in cosmo/account/create.js where i add the field while making the
user hash in
**********************************************************************
this.formToUserHash = function(){
alert(form.alternateEmail.value);
var user = {
username: form.username.value,
firstName: form.firstName.value,
lastName: form.lastName.value,
email: form.email.value,
alternateEmail: form.alternateEmail.value,
password: form.password.value
};
alert(user['alternateEmail']);
if (form.subscriptionName || form.subscriptionTicket ||
form.subscriptionUuid){
user.subscription = {
name: form.subscriptionName.value,
ticket: form.subscriptionTicket.value,
uuid: form.subscriptionUuid.value
}
}
return user;
};
************************************
as u can see i have entered a new alternate Email.(dont go upon alert. this
is for debugging purpose)
4. Have made changes in the cosmo.cmp.userhashToXml to cahnge the hash
object in the xml
***************************
userHashToXML: function(/*Object*/ userHash){
alert('in userHashToXMl'+' '+userHash.alternateEmail);
var isRoot = userHash.username == "root";
return '<?xml version="1.0" encoding="utf-8" ?>\r\n' +
'<user xmlns="http://osafoundation.org/cosmo/CMP">' +
(userHash.username && !isRoot? '<username>' +
cosmo.util.string.escapeXml(userHash.username) + '</username>' : "") +
(userHash.password? '<password>' +
cosmo.util.string.escapeXml(userHash.password) + '</password>' : "") +
(userHash.firstName && !isRoot? '<firstName>' +
cosmo.util.string.escapeXml(userHash.firstName) + '</firstName>' : "") +
(userHash.lastName && !isRoot? '<lastName>' +
cosmo.util.string.escapeXml(userHash.lastName) + '</lastName>': "") +
(userHash.email? '<email>' +
cosmo.util.string.escapeXml(userHash.email) + '</email>': "") +
(userHash.alternateEmail? '<alternateEmail>' +
cosmo.util.string.escapeXml(userHash.alternateEmail) + '</alternateEmail>':
"") +
(userHash.subscription?
this._subscriptionToXML(userHash.subscription) : "") +
(userHash.administrator && !isRoot? '<' + EL_ADMINISTRATOR +
' >true</' + EL_ADMINISTRATOR + '>' : "") +
(userHash.locked?'<locked>true</locked>' : "") +
'</user>';
},
**************************************
5. i have made changes in the userlist.html by adding the template for the
alternate mail as
***************************************
<tr>
<td><label for="loc">${l10n.Email}: </label></td>
<td><input dojoType="dijit.form.ValidationTextBox" type="text"
id="${id}Email"
name="alternateEmail"
regExp="${validation.alternateEmail.regExp}"
required="${validation.alternateEmail.required}"
invalidMessage="${validation.alternateEmail.invalidMessage}"></td>
</tr>
*********************************************
but now i have stuck somewhere. i am telling you where i am stucking. i am
trying to access my alternate mail in
***************************
cmpUserXMLToJSON: function (/*Element*/ cmpUserXml){
var user = cmpUserXml;
alert('Hi');
alert('************* ');
var obj = {};
obj.firstName =
user.getElementsByTagName("firstName")[0].firstChild.nodeValue;
obj.lastName =
user.getElementsByTagName("lastName")[0].firstChild.nodeValue;
obj.username =
user.getElementsByTagName("username")[0].firstChild.nodeValue;
obj.email =
user.getElementsByTagName("email")[0].firstChild.nodeValue;
obj.dateCreated =
user.getElementsByTagName("created")[0].firstChild.nodeValue;
obj.dateModified =
user.getElementsByTagName("modified")[0].firstChild.nodeValue;
obj.url =
user.getElementsByTagName("url")[0].firstChild.nodeValue;
obj.locked = (dojo.trim(
user.getElementsByTagName("locked")[0].firstChild.nodeValue)
== "true");
obj.administrator = (dojo.trim(
user.getElementsByTagName("administrator")[0].firstChild.nodeValue) ==
"true");
obj.unactivated =
(user.getElementsByTagName("unactivated").length > 0)?
true : null;
obj.homedirUrl = (user.getElementsByTagName("homedirUrl").length
> 0)?
user.getElementsByTagName("homedirUrl")[0].firstChild.nodeValue: null;
return obj;
},
*****************************************************
But it is not reaching there. i tried to debug it and reached at the
conclusion that when i am making the xml from the userhash, it is creating
problem (I tried to comment the code i write in userHashToXML: function(),
and all working fine). But i have to add the element in the xml. It is
sure that xml is creatin. i have debug that.
i also reached at one conclusion that in the code
**********************
getSignupXML: function(/*Object*/ userHash,
/*Object*/ ioArgs){
var requestDict = this.getDefaultCMPRequest(ioArgs);
requestDict.url = this._baseUrl + "/signup";
requestDict.putData = this.userHashToXML(userHash);
alert('return 1 from getSignupXML');
return dojo.rawXhrPut(requestDict);
},
*************************
The variable requestDict is coming from
*******
var requestDict = this.getDefaultCMPRequest(ioArgs);
************
but what is the ioArgs and where it is defined. Where all the io Args are
defined. i am not getting this. Please help me out with some reasons so that
i will be able to send the data successfullt to the CMPServlet in the
service layer.
Thanks in advance.
thank you
regards
Vaibhav Saxena
--
VAIBHAV SAXENA
Jr. Software Developeer
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev