6 Replies Latest reply on Nov 1, 2008 7:52 AM by Ronald van Kuijk

    JSF setting default values

    John Wooten Newbie

      Please direct me to the proper forum.
      Using jsf tag <h:inputText and not getting what I expect.

      <h:inputText name="ext-inputs" value="#{var['ext-inputs'] == null ? '40' : var['ext-inputs']}" type="text" ... />

      On first encounter on the page, it puts a '40' on the page with no complaints.
      But on a return to the page ( where the variable ext-inputs has been set to '40', I get an error about a "illegal syntax for setOperation"

      How do I make it so I provide a set of defaults, but afterwards use the set value?

        • 1. Re: JSF setting default values
          John Wooten Newbie

          Okay, trying to nav to two different places depending upon a variable that gets set by an action.

          here is the n:nav tag

          <n:nav outcome="transition" url="#{nid == '0' ? 'home.jsf' : 'task.jsf?id=#{nid}'}" storeMessages="true" />

          Now I think that the expression parser is getting confused because there is a #{variable} inside of the outside #{string}.

          Is there another way to do this? I'm thinking of writing a tag that takes a trueValueVariable and a falseValueVariable and a condition and target.

          If the condition is true, it assigns the trueValueVariable to the target, else it assigns the falseValueVariable.

          NOW, the question is will the n:nav tag handle a url="#{target}" where the target was the name of the target variable in the previous assignment via the action?

          • 2. Re: JSF setting default values
            John Wooten Newbie

            Written actionhandler but can't set value

            I have code that writes out the following when used as a tag
            <sj4j:updateVariable name="destination" trueValue="home.jsf" falseValue="task.jsf?id='#{nid}'" condition="#{nid == '0'}" />

            nameValue = destination ( String.class )
            trueValue = home.jsf (String.class)
            falseValue = task.jsf?id='580' (..)
            conditionValue = false (...)

            NOW, I then do a

            if( conditionValue.toString().equals("true") )
            this.nameExpression.setValue(context, trueValue.toString() );
            this.nameExpression.setValue(context, falseValue.toString() );

            in my tag action listener.

            I get the following error when the tag is executed.

            Error updating variable: An exception of type "javax.el.PropertyNotWriteableException" was thrown ...name="destination: Illegal Syntax for Set Operation.

            Question is how to set the variable destination in the action listener?

            • 3. Re: JSF setting default values
              John Wooten Newbie

              Found problem in that "destination" isn't writable, but "#{destination}" is.
              When I replace that, it doesn't complain and my log indicates the variable has been set to the desired value.


              that value is "task.jsf?id='579'" instead of task.jsf?id=579" for one thing.

              The other is, whether url="#{destination}" will process that correctly.

              • 4. Re: JSF setting default values
                John Wooten Newbie

                removed the ' ' around the inner part and the log says task.jsf?id=583, which is the next task. Thus the url="#{destination}" should have taken me to the task.jsf page with the id=583 and that would have shown me the proper page, instead I got a re-render of the page and that brings up the comment page since the id was still the previous ended task.

                BTW, if I hard code in the url="task.jsf?584", when I know what the next task number will be, it works fine and gives me a new page for the next task.

                • 5. Re: JSF setting default values
                  John Wooten Newbie

                  I've gotten the go to next screen working when the user can service the next task by creating my own version of <j4j:completeTask and adding an optional parameter nextId. It does some figuring out and sets the nextId to '0' if the user cannot service the next task, and to the id of the next task if servicable. If that variable is nid, then

                  In the <n:nav outcome="transition" url="task.jsf?id=${nid}" />

                  moves completely nicely to the next task!

                  However, if the nid from above is '0', then I get an exception that the task 0 can't be instantiated. In that case I'd like to redirect to "home.jsf"d which is where I have the task list.

                  Is there a way I can do that? I can't find a generic forward, redirect, or exception inside the console itself to have a default error page. In my case I'd make it "home.jsf" and not show the messages and be happy.

                  • 6. Re: JSF setting default values
                    Ronald van Kuijk Master

                    Most is basic jsf stuff so should be discussed in a jsf forum or the gravel forum. j4j stuff is for the jbpm user forum, but since the developer no longer works on the project I'm afraid you are on your own (as you were in this topic ;-)) The jBPM dev forum is not the correct place.