Results 1 to 5 of 5

Thread: Number Field Logic

  1. #1

    Question 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

  2. #2
    Join Date
    Jun 2010
    Posts
    440

    Default

    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

  3. #3

    Default

    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"

  4. #4
    Join Date
    Jun 2010
    Posts
    440

    Default

    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.

  5. #5

    Default

    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
  •