How to Modify Liferay User Registration? - java

I'm currently trying to extend the Liferay create account process so the user gets asked to provide his or hers telephone number and address during registration.
I know that Liferay supports the concepts of custom fields and I have managed to add them to the registration form and persist them to the database. However, out of the box, Liferay has support for phone numbers and addresses to be associated with an user account. I don't think it is a sound development technique to use custom fields for something that is already there.
Anyways my question is, what is the preferred technique to ask for an address and/or a phone number during registration? I tried hooking to the Struts registration action but I don't think that is the solution, in order to use the PhoneLocalService ot AddressLocalService I need a user ID and I get the user ID after I add the user to the database.
I admit hooking and extending Liferay is a bit of a mess for me right now, so any advice will be appreciated.

Unfortunately, the standard customization is quite limited (with a few properties you can turn on-off some features, like the captcha, or the prefix-postfix titles, etc., but nothing complicated).
The only way to customize registration JSP and the contacts JSP, mix them up and put it into the hook as the registration form.
I have done the exactly same thing as you need here, and I must say the handling of addresses and phones is a complete mess on first sight (it is done with auto forms, because you can have multiple ones). After throwing out the unnecessary code though it is quite straightforward to include a fix number of phone/address on the registration form.

Related

Devise customization for registration and confirmation

I was just about to follow this tutorial:
http://eureka.ykyuen.info/2011/03/03/rails-%E2%80%93-add-custom-fields-to-devise-user-model/
But then realized that my Devise needed some customizing. I am very new to Rails, so sorry for anything in advance.
What I am doing:
I need to create a site for a Minecraft server a friend and I are making. I set up devise with no extras, just an access level (admin, moderator, developer, ranks, etc.). I am using mongoid for everything here.
What's the problem? I need to make sure that the user really owns their minecraft account! The way I want to do it: In game you type /register [email], you are sent an email with a confirmation link, you click it and done, you are now registered.
What I am asking: Can someone guide me as to: What I need to do in Java, simply what's needed to be done, not the code (in PHP I've done this before, I opened up a connection to a page, I sent username and a hash as parameters), and what must be done in Rails (Change up some views, totally redo the insides of Devise, just what's needed, and some examples). I'm quite new to rails, so please be nice to my brain! Thanks!
I understand it's a big request for help, but if you have some idea of how this can be done, please help. Thank you for reading!
Edit:
Okay... I really am getting desperate here, I will make it as simple as I can:
How do I customize Devise confirmation? I want it like this: from JAVA I can create a user (with only his username and email) who can't log in because he hasn't confirmed yet. When the site gets this request to make an account, I want to dispatch an email with mailer with a confirmation link. From there, instead of just going ahead and verifying, I need them to type their password and reconfirm it, because remember: the account was created without the password, only username and email! After they fill in the form, their account is active!
Please help, I need this done quickly, my app is quickly growing and it will be a hassle to change this all. Until someone can help me, to make things better in user I am using a method to get what display name I want them to use, right now it's set to email, after someone helps me I can finally make it username!
Thank you for reading, please reply if you know the answer or upvote so someone can provide a good answer!
(Assuming that you already added the username field to the User model created by Devise)
What I would do:
Create a simple form, no Devise at all, just a standard form that takes the username and the email.
Email the user. This email will have the Devise form and/or a confirmation link.
If placing the Devise form in the mail is not possible, have it displayed in the page linked by the confirmation email. Of course, you can now auto-complete all the fields except for the password.
With this approach you don't have to dig in the guts of Devise. Use it out of the box, but until the second interaction with the user.

How to implement custom search on the server database in Android 2.3?

I have to implement custom search in my application for android 2.3.I have some EditText in which user type one letter and then I send response to the server, retrieve all the results matches this one letter and then I need to display them in a list. When user types second button I also need to send new response and refresh data and so on.
The question how can I do this in Android 2.3? What should i use?
This seems to be too open ended with too many questions to give a really helpful answer.
What you use in your app will heavily depend on how the server's API is expecting you to communicate. I, for one, am all for hiding the specifics of what a server does from the application and put all the "smarts" behind the API. So a query like:
http:/blah.com/getresults?search=a
would result in whatever matches 'a'. If it is searching a MySql Db, processing a Google search, or accessing files on the system doesn't matter.
Your code needs to worry about the interface to the API to make queries and processing the results, whether they're free formatted text, JSON objects, or whatever.
Maybe rewording your question or provide information on what you know would help.

How do I save a viewer response to a server?

If I want to save a response to a query on a website I'm coding to a server, how would I do that?
Here's an example. If I had a site with a "Rate us" form, and a person answered with a "AWFUL SITE!" how would I be able to save & retrieve that information?
There are several ways to do what you want to do. I'll describe two of them.
You could append each rating to the end of a file on the web server. This would be done in a server-side scripting language usually, such as PHP or ASP.NET, and you would probably want to set the permissions on the file so that it's not readable to everyone.
You could set up a table in a database (MySQL or otherwise) and add a new row for each rating given. Again, this would be done in something like PHP or ASP.NET and you would want to make sure you take precautions against SQL injection attacks (not much of a problem if you use PHP Data Objects rather than the deprecated mysql_* functions).
I would personally go for the second option as it's easier to manage and change, and it's easier to set it up so that you can store IP, name, optional email and message in every row. And like I said, you can add a new field later down the line without running into the obvious problems.

how to bookmark a dynamically created aspx page?

There is this site wich in the address bar only shows like "http://example.com/examplepage.aspx".
Normally if it would have parameters behind it you probably could just copy that one.
But since it doesn't, how do i bookmark this page.
It doesn't necessarily have to be a bookmark, but at least an easy way to access the page.
(fyi I know basic HTML and Java, maybe it's only possible programmatically).
thnx
Generally dynamic pages (taking in context with the question) are not book mark friendly.
You could probably sniff the incoming request, and create a fake form which you can then submit later.
However there may be situations where there are parameters such as session id which are valid for only small periods of time.
You should read up on sessions. In really simple terms, a session is assigned to users accessing a website. They have an expiry period. IF you stay idle beyond set time (determined by the developer) you will not be able to get in. And every time you log back in, you may be assign a new session.
You would have noticed, that some websites automatically log you in, this is mostly done with the help of cookies. Cookies work in tandem with sessions, they store very basic information, so the next time you come back to a website, it will be able to identify you as a returning user and provide you with access.
Then again, some pages don't use sessions, they might have their own custom way of identifying users.
Bookmarks can be used in dynamic pages, if the code allows you to send GET requests, if they don't have any other extra parameters which will block you.
To Summarize:
Dynamic page not very bookmark friendly.
There may be parameters used to access a webpage which change constantly, which you cannot really save.
You may be able to get into dynamic pages using bookmarks, if they don't use any of the dynamically changing parameters.
Since you know Java, you should probably read up on JSPs/servlets to get an understanding of what happens behind the scenes in dynamic pages.
Hope this answers your questions.

Billing Address is the same as Mailing Address

I'm using Spring MVC and have a page in my web application where I have a mailing address field that is mandatory and a radio button with a question asking 'Is the billing address the same as the mailing address?' Neither yes or no is selected by default to force the user to select an answer to the question via validation.
I have currently implemented it so that in the controller, if the radio button value is 'Yes', I copy the value of the mailing address into the billing address.
My validation works like so:
If the radio button has been set to yes then don't validate the billing address input fields, otherwise perform validation on those fields.
Is this an ok way to implement this functionality? The only other thing I could think of is to get JQuery to populate the values when the radio button is selected.
Why would you do the copying in the Java controller code versus Javascript?
I havent worked with Spring, but validation issues are aapplication wide, dispite of the framework. I've seen something in my development years, that you must know, is that validation should be performed on the server side and on the client side.
Always remember that Javascript validations can be bypassed using Firebug, or some other Mozilla plugin, but server validation is harder/almost impossible to bypass. Keep this in mind before you make the desition of leaving validation only for Javascript.
Hope I can help!
I agree with dconde, the only thing I would suggest is disabling the Billing Address fields in the UI if the user selects "Billing Address Same". This will provide concrete visible feedback that there is no need to enter values

Categories

Resources