Announcement Announcement Module
Collapse
No announcement yet.
Number Field Logic Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #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"

      Comment


      • #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.

        Comment


        • #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.

          Comment

          Working...
          X