-
Aug 1st, 2011, 05:34 PM
#1
Number Field Logic
I have a number field in one of my entities. I need to add some logic that this field can only take numbers that are powers of two and if it isn't then an error should be thrown to the user.
I have no idea where to start with this, I'm fairly new to web development. I was thinking I could push in the setters and getters for the number field and add logic there but then how will the appropriate error be thrown?
/confused
Thanks
-
Aug 1st, 2011, 05:50 PM
#2
You can use following formula...
log(n)/log(2) = an integer; means n is a power 2 number.
There might be other ways for getting it. At least you got one now.
Roogards
jD
-
Aug 1st, 2011, 05:55 PM
#3
I know what formula to use I'm just having trouble executing it on a roo project. i.e. Where/what file does this piece of code go into? How do I make sure an error is thrown so the user sees "Invalid number not a power of two"
-
Aug 1st, 2011, 06:09 PM
#4
You know the hard part then... The other part could be like this:
1) client side way: In the entity create.jspx using javascript.
2) server side way. In entity controller loading the message error in the returning model object.
-
Aug 2nd, 2011, 06:51 PM
#5
Sorry could you give me a little more information on how to do this? How do i create a .jspx in the entity?
It also would be helpful if I had more details on how to exactly do it in the server side way you described.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules