3 Replies Latest reply on Sep 10, 2009 6:37 AM by nbelaevski

    Croptool - needed advice about new components architecture


      Hello !
      I'm writing custom component named Croptool based on Jcrop javascript from http://deepliquid.com/content/Jcrop.html. I'm using CDK, and already have created component that outputs javascript function that initializes javascript.

      My component now submits java.awt.Rectangle as a value, which represents users selection. However the image cropping functionality is not in my UIComponent, but is delegated to via metod binding to some other bean, which is not part of component.
      Please, tell me how should my component be organized.
      1. Should it only set that Rectangle via value binding or can it do the cropping ?
      2. If it can then how can i call a method on UIComponent ?
      3. If it cannot, shall i ship my component with JSF bean that can be a sample and do the job ?

        • 1. Re: Croptool - needed advice about new components architectu


          Bean is definitely not an option. How about updating value expression + value change listener that will allow external bean to crop the image?

          • 2. Re: Croptool - needed advice about new components architectu

            Right now cropping action and holding image is responsibility of external bean, and my component just provides selection coordinates. It also outputs only JavaScript. I'm thinking about providing whole panel with buttons, buttons, but actually other users may want to add other actions, i.e. grab selection, but not crop. That could be done via facets i guess.
            I wrote facelet template using my crop component that i can reuse in several places in my project, it has lots of rerendering and other logic, that would be repeated if my rich component generates javascript only. Facelet template however has problems with passing action method bindings.
            Maybe I should provide another jar with sample bean and facelet template ?

            • 3. Re: Croptool - needed advice about new components architectu

              That depends on how wide you are planning to distribute the component. Note then none of RF components uses predefined beans.