how to inject arbitrary javascript code to a component markup?
Suppose I write my own wicket component called XYZ that have the following markup wicket:panel div wicket:id=id_xxx /div /wicket:panel How can I inject some js code into this markup so when it's rendered in a page, I got something like wicket:panel div wicket:id=id_xxx script type=text/javascript var data=[abc, efg]; document.write(data[0]); /script . div wicket:panel You may ask why I dont simply keep the js code into the component markup XYZ.html, this is because the value of data variable will be provided by the user and is not fixed.
Client-side treeView
Hello, I would like show a treeview like the following, root |---dir1 ||leave 1.1 ||leave 1.2 |-leave 0. 1 |-leave 0.2 This view should also allow a user to select multiple leave nodes (think of selecting multiple catagories to charaterized a product). I checked the TreeView/TreeTable components in Wicket-Ext and found that they need to communicate with the sever-side every time a node is expanded or collapsed. This is a waste of bandwidth in my case, as my tree model never changes. Any suggestion on how I should implement a fixed treeview on the client side, and only pass data to the server after the user clicks a submit button?
ProgressBar demo doesn't work for firefox 3.5.3
I copy and paste the single file upload demo at http://www.wicket-library.com/wicket-examples/upload/single; to my local machine and found the the ajax progressbar doesn't work on my firefox 3.5.3 on winxp. But It works on my ie 8 though. Any idea what might be the cause? ( I did not change a single a line of code, I am using wicket 1.4.1) BTW: the file upload demo on wick-library.com does not work. I got a internal error message every time when trying to upload a file. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: User name validation - how to check database to find if a name has already been taken?
igor.vaynberg wrote: form { onsubmit() { try { users.persist(getmodelobject()); } catch (usernamealreadyexistsexception e) { error(error.username.exists); } } } -igor Thanks, it works like a charm. I did not know I could show an error message by calling Component.error and then use a filter to catch all error messages targeting a specific FormComponent. -- View this message in context: http://www.nabble.com/User-name-validation---how-to-check-database-to-find-if-a-name-has--already-been-taken--tp25614625p25682499.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: User name validation - how to check database to find if a name has already been taken?
The AbstractValidator approach is fine, or you can do it the shorter way the Igor showed. Either way, when the page that has the username is submitted, you're going to have to write that record to the database, even if you don't have all the info. The way you wrote the question, I presume you are collecting info on multiple pages. First page gets username et al, then next as in a wizard page. When you check the username and it's not in use, write the record. The table should have audit columns that include record_status and last_mod_datetime. Initially write the record with status I (in process) and when the user is finished registering, update it with A (active). If the user fills out page 1 and then closes the browser you'll have a record there with status I. You'll need a job that fires off periodically (I do it once a day at 2 or 3am) that finds those records that are more than, say, 24 hours old, and purges them. Then, to quote a sith, there is no conflict. -hth Thanks for your suggestion. Currently, I only have a single user input page. But as the application evolves, I may eventually need to have a wizard and implement the record_status check process as you suggested to make sure that the database is always consistent. -- View this message in context: http://www.nabble.com/User-name-validation---how-to-check-database-to-find-if-a-name-has--already-been-taken--tp25614625p25682624.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
User name validation - how to check database to find if a name has already been taken?
Hello, I would like to get your suggestion about how to validate a user name input by checking if the name has already been taken (exists in the back-end database); and how to show feedback messages right next to the input field if it has. Typically, when a user registers to a website, he needs to choose a user name, a password, etc. To make sure that the chosen name is unique, one needs to access the back-end database to check if it already exists. My solution right now is to extend AbstractValidatorString, and override onValidate(IValidatableString validatable) to put the database-checking logic in it. But the more I think about it, the more I felt it might be a wrong solution. The problem (I think, not 100% sure) is that onValidate(IValidatableString validatable) will be called during the form validation process, even if this process goes through, I may still find out later that the user chosen name has been taken when trying to save all the user inputs (name, password, etc) to the database. This happens when another user registers with the same name between the time the validation process finished and the time I start persisting all inputs from the first user to the database, So now I am trying to figure out another solution. Here is the idea: Instead of putting the database-checking logic into the validation process, I simply try to save all the user inputs into the database after receiving them. If an unique key exception happens, I know that the user chosen name has been taken. Now my questions are: 1. where should I put this save-catch-exception logic? Is Form.onSubmit() the right place to put it? 2. After I catch an unique key exception. How can I show a feedback message like This name has already been taken RIGHT NEXT to the user name input field? (Just like what a typical Wicket Validator does though FeedbackPanel). I am new to Wicket and your inputs and suggestions are greatly appreciated. Cheers Paul
Re: User name validation - how to check database to find if a name has already been taken?
Ryan Gravener-3 wrote: I think you are overcomplicating things. Validate the users input, if two users want the same name within 1 second of each request you probably have bigger problems to deal with. So you think my current solution (extending AbstractValidator) is OK? But I still need to catch nonunique exceptions when saving all user inputs. Anyhow, when submit is called, if you get a nonunique exception. Catch in dao/service and throw an exception wicket can handle and present. Ryan Gravener http://bit.ly/no_word_docs For additional commands, e-mail: users-h...@wicket.apache.org Can you be a little bit more specific? After I catch a nonuqniue exception, how should I change the page markup to present an error message? Any examples/references will be helpful. -- View this message in context: http://www.nabble.com/User-name-validation---how-to-check-database-to-find-if-a-name-has--already-been-taken--tp25614625p25615006.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org