4 Replies Latest reply on Oct 19, 2012 2:04 PM by Viacheslav Kabanovich

    JBoss tools JSF development - extending VPE (for MBean property)

    Kaushal Kumar Newbie


      JBoss tools eclipse plugin for JSF development provides visual representation of UI and provides a mechanism to drag and drop JSF component (Core JSF and Richfaces) on Visual editor.

      We are trying to get a similar feature where user should be able to drag and drop managed beans properties on Visual editor, which should create the corresponding JSF component (depending on the data type of the element) on visual page editor.

      For e.g. if user drags an element (of data type String) and drops on the VPE then a pop up should come up where he selects the type of input component he wants and say ok. This eventually will add the code corresponding to JSF (along with databinding) on VPE.


      We observed that "Web Projects" view (which is provided by JBoss) lists all the managed beans and user can drag and drop bean properties on Visual editor. When the user drops the element on VPE then value binding gets added to it.

      Is there a way to add a hook between these (Web projects plugin and VPE plugin) to achieve our objective.


      Or is there some other mechanism to achive this (may by extending any plugin etc.).





        • 1. Re: JBoss tools JSF development - extending VPE (for MBean property)
          Viacheslav Kabanovich Newbie

          At present, dnd to VPE does not provide an extension point. We have implemented three cases of dnd: items from Palette, bean attributes from Web Projects, files from Package Explorer. When a file is dropped, a wizard is displayed with choice of relevant tag to be inserted (e.g. for xhtml it is ui:include and s:decorate; all available options are described in code). A similar wizard could be displayed when a bean attribute is dropped. Then, we have to provide an extension point to allow adding proposals for custom components and binding them to bean attribute type. Please add a feature request to JBoss Jira for JBossTools project.

          Alternatively (or in addition), should we provide an opportunity for a user to bind data types and components in preferences, so that on a bean attribute drop, the wizard would read suggestions from preferences rather than from added plugins? Not many users would bother to write plugins to extend a feature, it is easier to customize it in preferences.

          String bean attribute can be bound to most attributes of most JSF components, should wizard try to show them all, or only some 'favorite' options?

          • 2. Re: JBoss tools JSF development - extending VPE (for MBean property)
            Max Rydahl Andersen Master

            How would you make a preference for allowing users to define what is to happen for unknown objects ?

            • 3. Re: JBoss tools JSF development - extending VPE (for MBean property)
              Kaushal Kumar Newbie

              Thanks for your reply

              Let me just say what i have done so far

              We have created a plugin which adds a drop listener to JSPMultiPageEditor. This listener is called after the Jboss listner execution and it opens a dialog window where user can select some basic component.

              Once the user selects a component type, we create corresponding jsf code for that, erase the text which was added by JBoss code and add this JSF part to the editor.

              I feel that this is a crude way, but it would be nice if you could suggest me a better way


              We observed that there are some classes (like FileDropCommand, PaletteDropCommand, PlainTextDropCommand etc.) which do the work of drop, and there is a class DropCommandFactory which decides the drop command to be used.

              Is there any mechanism to register our custom drop command to this list?




              Thanks for your suggestion, I will definitely add this as a feature request. I am in agreement with you on reading suggestion from preferences, but there sould be a way to extend the suggestions (or may be a way to add additional attributes).

              I was feeling that if org.jboss.tools.jst.web.ui and org.jboss.tools.jst.jsp plugin would have exposed extension points on these areas then it would have been easier for us to extend it.

              Regarding the choice of UI component for attribute, i think we can set a default behaviour (for e.g. a collection of Address can be shown as a grid), but we should give choice to user to change it or may be extend it.


              Max -

              Today, if we drag and drop a Non-managed bean component from "Web Projects" view on JSPMultiPageEditor, then a pop up window is shown which asks about the corresponding managedbean name.

              So we would try to gain advantage of such feature.

              I am not very clear on what do you mean by "unknown objects". Assuming that you mean a reference attribute for a custom class (for e.g. a Person reference (which comprises of fname (String), lname (String) etc.). In this case will like to get the entire object getting formulated on UI, i.e. a <h:panelGroup> component which bundles all the sub components (like fname, lname (as <h:inputText> etc. ) together). I understand this will be a bit tricky

              • 4. Re: JBoss tools JSF development - extending VPE (for MBean property)
                Viacheslav Kabanovich Newbie

                Suggesting preferences, I meant only the drop of bean attributes from Web Projects view, that is, objects well known for JBoss Tools. Preference could map Java type of bean attribute to {tag library uri + tag name + attribute name to put EL in}, or even to a snippet where user will specify all sub components (thus, user writes snippets for Java types available in his project, that is, for objects well known to him). Then the drop would be processed in the same way as it is for a Palette item, with the only difference that a specified attribute will be prefilled by EL. Maybe for common Java types like String this functionality will not be of greate advantage, but for specific cases like List<Person> user might find quite helpful to have a nice snippet and apply it with one mouse drop.


                There is now no extension point for registering new implementation of IDropCommand. We can readily add such a point, but I think we may allow to bind it only with a new transfer data type to prevent it from conflicting with existing IDropCommand implementations. In this way, dnd from some new view may be supported. For currently supported transfer data types, we can provide extensions through the existing implementations. For example, for the drop of bean attributes from Web Projects view, PaletteDropCommand may request extensions if they have for a given bean attribute to provide a snippet (or choice of snippets) and/or wizard to customize it (then the above-mentioned usage of preferences is an example of implementation of that extension).