5 Replies Latest reply on Jul 14, 2007 3:20 PM by nathan dennis

    Dynamic view for s:button control?

    Mihai Anescu Newbie

      Hi,

      I have this situation:
      1) a combo box with several values and
      2) a button.

      After the user selects a specific value from the combo box, when the button is clicked a specific page will be displayed. (some sort of pageflow, if you wish).

      This could be done very easy in plain Javascript, just change the value of the URL used by the button, based on the current value of the combo box.

      How can you implement such a feature in Seam/JSF? I tried to create a component to keep the current value of the combo box and use it to render the button, but this is not working, the button will have the initial value of the atrribute.

      EX: I have a hierarchy, with 2 child classes, B and C, both extending A.
      I have somewhere a link "Create new A", this leads me to a page with the combo box, where I can choose between B and C. Then I click the button which will forward me to the correct edit page, either B or C.

        • 1. Re: Dynamic view for s:button control?
          Stuart Robertson Novice

          s:button results in a get, not a post. I think you want h:commandButton.

          • 2. Re: Dynamic view for s:button control?
            Mihai Anescu Newbie

            I don't need a post.

            I just need 2 URLs, one for each value in the combo box. As I said, in Javascript + Struts this would mean something like 10 lines of code.

            The flow would be:
            1) I select value C from combo
            2) I click the button
            3) I end up on the C specific page (used to add a new entity of type C, in this case).

            So no post/page reload should happen between 1 and 2. I also would like to keep as simple as possible.

            • 3. Re: Dynamic view for s:button control?
              Carsten Hoehne Master

              Sorry, i do not have a ready made solution for you, only some ideas.
              Asyou said you will have to use javascript.
              (There are many frameworks for javascript out there.)
              1. I suggest to try richfaces.
              You will ajaxenable the combobox in a way that you are able to rerender the button.

              2. Use a menu (richfaces has one)

              3. Make your solution with javascript only. Surely hard to do, but possible.

              4. one jsf-way to do it:
              When the button is clicked an action is triggered. This action will check the selected value of the combobox and returns an outcome. The navigation rules of your application will navigate to the page which is determined by the outcome.

              Hope this helps enough to get an idea for the direction to work further.

              • 4. Re: Dynamic view for s:button control?
                Mihai Anescu Newbie

                Hi,

                tnx for the solutions.

                I already implemented it with no 4 (action + navigation rules), but it would be more user friendly to use the richFaces dropDownMenu component (i've seen the demo on exadel's site).

                However, when I try to use it on a page, I get this error:

                <rich:dropDownMenu> Tag Library supports namespace: http://richfaces.ajax4jsf.org/rich, but no tag was defined for name: dropDownMenu


                I'm using Seam 1.2.1 and a seam generated project, with the default libraries. Is this a new developed component from richFaces?

                • 5. Re: Dynamic view for s:button control?
                  nathan dennis Expert

                  im sure it is something simple... but im having the same trouble with the same revision. anyone figure this out? i really dont have haft a day to waste looking for it.