DataTable - CommandButton doesn't work even inside p:column

UI Components for JSF
Daedin
Posts: 25
Joined: 04 Dec 2010, 13:24

27 Dec 2010, 01:06

Hello,

I have a commandButton inside a DataTable. However the "action" isn't called when I click on it (same effect with an actionListener); I added logs at the beginning of the server action, and it never shows.
Please note that the button works fine when outside from the datalist.

Here is my code:

Code: Select all

 <h:form id="compSearchForm">
	<p:dataTable var="competency"
		value="#{competencySearchBean.matchingCompetencies.toArray()}">
		<p:column>
			<f:facet name="header">
				<h:outputLabel value="Title" />
			</f:facet>
			<h:outputText value="#{competency.title}" />
		</p:column>

		<p:column>
			<p:commandButton value="Go" id="actionButton"
				action="#{myBean.doAction}" />
		</p:column>
	</p:dataTable>
</h:form>
Would you have any idea as to what the issue might be?
Sébastien

JavaServer Faces 2.0
Primefaces 2.2 RC2
Tomcat 7.0

Daedin
Posts: 25
Joined: 04 Dec 2010, 13:24

27 Dec 2010, 11:02

Just thought it could be linked to the fact that I specified an "id", thus producing several components with the same id. Just removed the ID tag, but it didn't solve the issue.
Sébastien

JavaServer Faces 2.0
Primefaces 2.2 RC2
Tomcat 7.0

lordpixel
Posts: 134
Joined: 17 Jun 2010, 17:46

27 Dec 2010, 13:25

Can you post the actionListener?

healeyb
Posts: 365
Joined: 07 Apr 2010, 16:05

27 Dec 2010, 13:53

Are you using f:viewParam on the page?

Daedin
Posts: 25
Joined: 04 Dec 2010, 13:24

27 Dec 2010, 14:28

The action is very simple:

Code: Select all

public String doAction() {
	System.out.println("In action");
	return null;
}
I have also tried to turn it in an actionListener

Code: Select all

public String doAction(ActionEvent event) {
	System.out.println("In actionListener");
	return null;
}
And I am not using any f:viewParam. I have tried to tinker a bit with the f:setPropertyActionListener though.
Sébastien

JavaServer Faces 2.0
Primefaces 2.2 RC2
Tomcat 7.0

westfarmer
Posts: 13
Joined: 11 Dec 2010, 09:38

27 Dec 2010, 21:44

is there another cascade form?

Daedin
Posts: 25
Joined: 04 Dec 2010, 13:24

27 Dec 2010, 22:56

No, this is the top form. I double-checked in the source code, and my button has an (automatically generated) id in the form: form_id:datalist_id:row_number:button_id
Sébastien

JavaServer Faces 2.0
Primefaces 2.2 RC2
Tomcat 7.0

healeyb
Posts: 365
Joined: 07 Apr 2010, 16:05

28 Dec 2010, 02:19

This line worries me a little. It sort of looks ok on detail however I would
just return a Collection<t> and have the var= pointing to a T.

value="#{competencySearchBean.matchingCompetencies.toArray()}">

Then refer to #{competency.name} or whatever.

If that doesn't help I'm going to load it into Glassfish and see what
happens, because it looks ok to me.

Is this an academic project?

Regards,
Brendan.

Daedin
Posts: 25
Joined: 04 Dec 2010, 13:24

28 Dec 2010, 11:04

In fact the "matchingCompetencies" is a java.util.Set instance, and can't be iterated through, which is why I use the toArray(). I'll try and change this to have the backing bean return a collection that can be iterated through by the datalist.
This isn't an academic project, but a personal one :)

Anyway, thanks a lot for your support. It's very kind of you.

EDIT: changed it a little bit to have the Backing Bean return a List<T> instead of a Set<T>, but the behaviour stays the same.
Sébastien

JavaServer Faces 2.0
Primefaces 2.2 RC2
Tomcat 7.0

Daedin
Posts: 25
Joined: 04 Dec 2010, 13:24

28 Dec 2010, 13:11

Don't know if this can help, but this is the generated HTML for the button:

Code: Select all

<button type="submit"
				onclick="PrimeFaces.ajax.AjaxRequest('/levelup/pages/protected/character.jsf',{formId:'compSearchForm',async:false,global:true,source:'compSearchForm:compSearchTable:0:compBuyButton',process:'@all'});return false;"
				name="compSearchForm:compSearchTable:0:compBuyButton"
				id="compSearchForm:compSearchTable:0:compBuyButton"
				class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
				role="button" aria-disabled="false"><span
				class="ui-button-text">Buy</span></button>
EDIT: and here is the HTML of the same button, but taken out of the datatable (which actually performs the action when I click on it):

Code: Select all

<button type="submit"
	onclick="PrimeFaces.ajax.AjaxRequest('/levelup/pages/protected/character.jsf',{formId:'compSearchForm',async:false,global:true,source:'compSearchForm:compBuyButton',process:'@all'});return false;"
	name="compSearchForm:compBuyButton" id="compSearchForm:compBuyButton"
	class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
	role="button" aria-disabled="false"><span
	class="ui-button-text">Buy</span></button>
The only difference between the two of them is the ID. I'll try and play with the "prependId" attribute a bit.
Sébastien

JavaServer Faces 2.0
Primefaces 2.2 RC2
Tomcat 7.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests