5 Replies Latest reply on Mar 21, 2010 9:22 AM by cheftimo

    Binding different events to a form depending if it is used for edit or create new.

    Aron manager

      Hi,

       

      I succesfully have separated presentation from logic (events, etc...) using the code behind article at adobe site. This is pretty nice but now I have a little problem. Think about I have two forms one for edit and the other to add a new user. Usually this forms are allmost the same only some logic change and just few controls if any.

       

      What I would like to do (don't know if this is best way to do it, for me it does):

       

      1) Create Add form.

      2) Create a view state to change this add form to edit when needed (I think just few changes if any will be needed)

      3) Now the problem, I need to bind different logic if I'm in edit or add new user form. Is there any way to attach different functionality

      to the form component to let it behave the way I need depending on the mode (edit or new)? I have seen include can be used but can it be used conditionally?

      Example:

          if( in edit mode)

              include ("src/usermanagement_editlogic.as"))

          else( in add mode)

              include ("src/usermanagement_addlogic.as"))

       

      As I previously said I'm pretty new to flex but I think this is a good way to do things and have everything splitted. If anyone has a better way to do it I would be really happy to hear it  .

       

      Thanks in advance,

      Aron.