CommandButton/Link inside p:tree doesnt work?

UI Components for JSF
alucardeck
Posts: 12
Joined: 22 Aug 2011, 15:56

02 Jan 2012, 14:57

Hi,

i am trying to use a both h:commandButton and p:commandButton (and h:/p:commandLink) inside a treenode in p:tree,
but it doesnt work.

test case:

Code: Select all

<p:tree value="#{testeNodeBean.storeMainNode}" var="pi" selectionMode="single"
							selection="#{testeNodeBean.storeSelectedNode}" >
							<p:treeNode>
								<h:outputText value="#{..some info here..}" />

<!--  HERE DOESNT WORK!! -->
								<p:commandButton ajax="false" action="#{testeNodeBean.test1()}" value="test" />
								<p:commandButton ajax="false" actionListener="#{testeNodeBean.test2()}" value="test2" />
                                                                <h:commandLink action="#{testeNodeBean.test1()}">
								      <h:graphicImage library="images" name="ok.png" />
                                                                </h:commandLink>
							</p:treeNode>
						</p:tree>

<!--  HERE IT WORKS!! -->
								<p:commandButton ajax="false" action="#{testeNodeBean.test1()}" value="test" />
								<p:commandButton ajax="false" actionListener="#{testeNodeBean.test2()}" value="test2" />
                                                                <h:commandLink action="#{testeNodeBean.test1()}">
								      <h:graphicImage library="images" name="ok.png" />
                                                                </h:commandLink>

Code: Select all

@SessionScoped
@ManagedBean
public class TesteNodeBean {	
	private TreeNode storeMainNode;
	private TreeNode storeSelectedNode;
	
	public TesteNodeBean(){
		storeMainNode = new DefaultTreeNode("ROOT",null);
               //populate storeMainNode here...
	}
		
	public String test1(){
		System.out.println("here!");
	}

	public void test2(){
		System.out.println("here 2!");
		return "";
	}

// GETs and SETs here...

}
i know, maybe people will suggest to make an outside button, getting the selected node, and do the action related to it..
but to make the UI dynamic for the user, i would like a workaround for that =/

thanks in advance =]

EDIT:
my PrimeFaces version is: 3.0.RC2

hckoalla
Posts: 1
Joined: 23 Nov 2011, 15:23

03 Jan 2012, 12:44

Hey,

i have the same problem using trees, i couldnt manage to make an action inside a treeNode component and i also need to pass the node value as parameter..
i also tried using p:ajax trying to listen to click events on the buttons, but didnt work. D:

can someone provide a workaround for that, please?? *-*

alucardeck
Posts: 12
Joined: 22 Aug 2011, 15:56

03 Jan 2012, 16:11

Hi,

yeah, you gave me the idea to try with p:ajax now, but i had no success too =/
even breakpoints arent called..

Code: Select all

 <p:commandButton value="test">
<p:ajax event="click" listener="#{testeNodeBean.test()}" update=":form:mainPnl" />
</p:commandButton>

if there isnt a workaround.. i will have to create a static button in the middle of screen to get the selectedNode and process =/

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

03 Jan 2012, 16:32

Really stupid don't be able to have p:commandButton inside of tree nodes. Otherwise, do you really need p:commandButton? Why not use <p:ajax event="select" ..../>? If you want to show a button, you can simulate it with a div element (h:panelGroup layout="block") and jQuery styles.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

alucardeck
Posts: 12
Joined: 22 Aug 2011, 15:56

03 Jan 2012, 18:36

Oleg wrote:Really stupid don't be able to have p:commandButton inside of tree nodes. Otherwise, do you really need p:commandButton? Why not use <p:ajax event="select" ..../>? If you want to show a button, you can simulate it with a div element (h:panelGroup layout="block") and jQuery styles.
hi, thanks for reply,

well, what i really would like is something like that:

- Node 1
- Node 1.1
- Node 1.1.1 (B1) (B2) (B3)
- Node 1.1.2 (B1) (B2) (B3)
- Node 1.2
- Node 1.2.1 (B1) (B2) (B3)
- Node 1.2.2 (B1) (B2) (B3)


consider B1/B2/B3 as commandButtons and commandLinks (with image inside)...
and in each command it will have add/remove/edit functions
that will render in a new panel on the right...

by the way... i also notice my node icons ' + ' and ' - ' disappeared in structure when i upgraded to 3.0.RC2
i tried to set expandedIcon and collapsedIcon in <p:treeNode>, but no success ...


i guess i will try a p:treeTable, and remove borders..

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Jan 2012, 12:23

Really stupid don't be able to have p:commandButton inside of tree nodes.
I don't think it is stupid, it could be a bug, it is not made on purpose or by design, file an issue and we'll look in detail. I'd use the word pity here instead of stupid. It is kinder and describes the case better.

I thought we had fixed the event and input processing in Tree and TreeTable in 3.0. Commands work in treeTable as in showcase sample, so it should work as well in theory as tree and treeTable both extends from UITree class which is a PrimeFaces API similar to UIData.

alucardeck
Posts: 12
Joined: 22 Aug 2011, 15:56

04 Jan 2012, 20:06

optimus.prime wrote:
Really stupid don't be able to have p:commandButton inside of tree nodes.
I don't think it is stupid, it could be a bug, it is not made on purpose or by design, file an issue and we'll look in detail. I'd use the word pity here instead of stupid. It is kinder and describes the case better.

I thought we had fixed the event and input processing in Tree and TreeTable in 3.0. Commands work in treeTable as in showcase sample, so it should work as well in theory as tree and treeTable both extends from UITree class which is a PrimeFaces API similar to UIData.
Well, its probably a bug, i didnt have time to test with p:treeTable yet,
but i opened a issue for now, hope to get a fix soon ^^
http://code.google.com/p/primefaces/iss ... il?id=3230

Thank you.
"Freedom is the right of all sentient beings" :P

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Jan 2012, 16:24

Fix checked in for 3.0.1 and 3.1.

cookiemonster
Posts: 17
Joined: 16 Dec 2011, 15:40

14 Jan 2012, 15:48

Hello,

Does
Fix checked in for 3.0.1 and 3.1.
mean if i download 3.0.1 or 3.1 and replace with my old version, my commandButtons in treeTable will work?

i tried 3.0.1 but could not get a successful result.

alucardeck
Posts: 12
Joined: 22 Aug 2011, 15:56

16 Jan 2012, 19:16

optimus.prime wrote:Fix checked in for 3.0.1 and 3.1.
Thanks, i tested in 3.0.1 (14/jan version), looks like it isnt working,
but i changed to 3.1-snapshot and its working now ! =]
Also, i am suspecting it isnt working on commandButtons with <f:ajax> <p:ajax> inside, but i will check it, if i find any problem i will open a ticket.
cookiemonster wrote:Hello,

Does
Fix checked in for 3.0.1 and 3.1.
mean if i download 3.0.1 or 3.1 and replace with my old version, my commandButtons in treeTable will work?

i tried 3.0.1 but could not get a successful result.
Change to 3.1-SNAPSHOT, its working there,
i also tried 3.0.1 (same day from 3.1-SNAPSHOT) and it wasnt working.

Not sure if Snapshot will give me problems, but i can hold it until 3.1 launchs...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 60 guests