Problem with webuijsf:tree and getSelected()

View: New views
5 Messages — Rating Filter:   Alert me  

Problem with webuijsf:tree and getSelected()

by Giulio Ferro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've noticed that I'm not able to get server-side the id value
of the selected TreeNode. I was developing a module and it didn't
work, so I carbon-copied the example in the docs:

http://webdev2.sun.com/woodstock-tlddocs/webuijsf/tree.html
(Example 4: Dynamic Tree)

and it didn't work either.

The problem is here:

-------------------------------------------------------------
| public String addNode() {

        String nodeId = getDynamicTree().getSelected();

        if (nodeId == null) {
            return "";
        } |
...
-------------------------------------------------------------

The getSelected always returns null, whatever node I click on and then
press "add child".

I don't know if I'm doing something wrong or there is some issue here...
I'm using netbeans 6.1 (last update) + glassfish v2 + sun java 6

Thanks for any help.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Problem with webuijsf:tree and getSelected()

by Antonin Karasek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
this is not a solution, but something, that can be helpful...

1. Make sure, that getSelected() really returns null. Try something like:

if (nodeId == null) {
            System.err.println("really null");
             return "";
         }

and watch the glassfish output in NetBeans...

2. Try to call getSelected() in actionExpression of a treeNode:

<webuijsf:treeNode id="folder1" binding="#{TestTreeBean.folder1}"
actionExpression="#{TestTreeBean.myMethod}" />

public String myMethod {
         System.err.println("selected:
"+getDynamicTree().getSelected());

         return null;
     }

-- I'm using getSelected() in actionExpression with exactly the same
configuration (netbeans 6.1 (last update) + glassfish v2 + sun java 6)
and it works...

Good luck :o)

Regards
        Tony

Giulio Ferro wrote:

> I've noticed that I'm not able to get server-side the id value
> of the selected TreeNode. I was developing a module and it didn't
> work, so I carbon-copied the example in the docs:
>
> http://webdev2.sun.com/woodstock-tlddocs/webuijsf/tree.html
> (Example 4: Dynamic Tree)
>
> and it didn't work either.
>
> The problem is here:
>
> -------------------------------------------------------------
> | public String addNode() {
>
>        String nodeId = getDynamicTree().getSelected();
>
>        if (nodeId == null) {
>            return "";
>        } |
> ....
> -------------------------------------------------------------
>
> The getSelected always returns null, whatever node I click on and then
> press "add child".
>
> I don't know if I'm doing something wrong or there is some issue here...
> I'm using netbeans 6.1 (last update) + glassfish v2 + sun java 6
>
> Thanks for any help.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Problem with webuijsf:tree and getSelected()

by Giulio Ferro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antonin Karasek wrote:
> Hi,
> this is not a solution, but something, that can be helpful...
>
Nope, it doesn't work.
I've tried the dynamic tree example
http://webdev2.sun.com/woodstock-tlddocs/webuijsf/tree.html
creating a new project with
a new Netbeans 6.5 installation both with linux and windows and
it's useless.

First of all, you have to change the actionListener to
actionListenerExpression
of the tree and the action to actionExpression of the button in the jsp,
otherwise it won't compile. I guess the example in the docs refers to an old
implementation of this component...

Then the getSelected() method _ALWAYS_ returns null, either in the
button's actionExpression method and in the actionListenerExpression of the
TreeNode.



> 1. Make sure, that getSelected() really returns null. Try something like:
>
> if (nodeId == null) {
>         System.err.println("really null");
>             return "";
>         }
>
> and watch the glassfish output in NetBeans...

It does return null, really null...

>
> 2. Try to call getSelected() in actionExpression of a treeNode:
>
> <webuijsf:treeNode id="folder1" binding="#{TestTreeBean.folder1}"
> actionExpression="#{TestTreeBean.myMethod}" />
>
> public String myMethod {
>         System.err.println("selected: "+getDynamicTree().getSelected());
>
>         return null;
>     }
>
Same as above...


> -- I'm using getSelected() in actionExpression with exactly the same
> configuration (netbeans 6.1 (last update) + glassfish v2 + sun java 6)
> and it works...

Can you try the example in the docs? Does it work for you?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Problem with webuijsf:tree and getSelected()

by Antonin Karasek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
sorry for the late answer. I'm a little busy this week (and probably
next few weeks). Try to compile and run the attached project and let me
know, whether it work for you (it works for me). It's a NetBeans 6.1
project.

There are just two components - tree and staticText. If you click a
treeNode, the staticText should display the treeNode id.

If it will work, double check binding attribute of tree component in
your project.

If you will not be able to find the problem, try to send me you project
(don't forget to clean it first).

Good luck :-)

Regards
        Tony

Giulio Ferro wrote:

> Antonin Karasek wrote:
>> Hi,
>> this is not a solution, but something, that can be helpful...
>>
> Nope, it doesn't work.
> I've tried the dynamic tree example
> http://webdev2.sun.com/woodstock-tlddocs/webuijsf/tree.html
> creating a new project with
> a new Netbeans 6.5 installation both with linux and windows and
> it's useless.
>
> First of all, you have to change the actionListener to
> actionListenerExpression
> of the tree and the action to actionExpression of the button in the jsp,
> otherwise it won't compile. I guess the example in the docs refers to an
> old
> implementation of this component...
>
> Then the getSelected() method _ALWAYS_ returns null, either in the
> button's actionExpression method and in the actionListenerExpression of the
> TreeNode.
>
>
>
>> 1. Make sure, that getSelected() really returns null. Try something like:
>>
>> if (nodeId == null) {
>>         System.err.println("really null");
>>             return "";
>>         }
>>
>> and watch the glassfish output in NetBeans...
>
> It does return null, really null...
>
>>
>> 2. Try to call getSelected() in actionExpression of a treeNode:
>>
>> <webuijsf:treeNode id="folder1" binding="#{TestTreeBean.folder1}"
>> actionExpression="#{TestTreeBean.myMethod}" />
>>
>> public String myMethod {
>>         System.err.println("selected: "+getDynamicTree().getSelected());
>>
>>         return null;
>>     }
>>
> Same as above...
>
>
>> -- I'm using getSelected() in actionExpression with exactly the same
>> configuration (netbeans 6.1 (last update) + glassfish v2 + sun java 6)
>> and it works...
>
> Can you try the example in the docs? Does it work for you?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

TreeTest.tar.gz (21K) Download Attachment

Re: Problem with webuijsf:tree and getSelected()

by Giulio Ferro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Antonin Karasek wrote:

> Hi,
> sorry for the late answer. I'm a little busy this week (and probably
> next few weeks). Try to compile and run the attached project and let
> me know, whether it work for you (it works for me). It's a NetBeans
> 6.1 project.
>
> There are just two components - tree and staticText. If you click a
> treeNode, the staticText should display the treeNode id.
>
> If it will work, double check binding attribute of tree component in
> your project.
>
> If you will not be able to find the problem, try to send me you
> project (don't forget to clean it first).
>
> Good luck :-)
>

Sorry for the late reply.
I've opened your project and it seems to work correctly.
I will try to understand what the problem was in my project, even though
it was pretty simple... I don't know what to think...

Thanks for your help :-)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...