p:commandButton's actionListener onClick event doesn't fire

UI Components for JSF
Post Reply
arnieAustin
Posts: 103
Joined: 14 Feb 2015, 22:35
Location: Austin, TX

13 Feb 2020, 03:02

I have a UI with a one form, a TabView, and two tabs. On the 2nd tab, where one manages the roles assigned to a user, there is a p:selectOneMenu (with the currently unassigned roles), a label, and a p:commandButton (Grant Role). Initially, the label says "Make a selection" and the grant button is disabled. When a selection is made, the label is updated to the description of the role and the button is enabled. All of this logic uses p:ajax event="itemSelect" along with an ajax update to show the new data. The listener method for the drop down has this signature.

Code: Select all

public void showSelectedRoleToGrantEvent(AjaxBehaviorEvent event) {
Then I click the grant button, the global p:ajaxStatus appears for a split second, and ... nothing. No call the server.

The markup for the button is:

Code: Select all

<p:commandButton id="cmdRoleGrant" rendered="#{not sysUserDTOEdit.readOnly}"
	value="#{messages.getString('sysUserEdit.tabRole.label.cmdRoleGrant')}"
	actionListener="#{sysUserRoleMembershipEdit.grantRoleListener}"
	disabled="#{!sysUserRoleMembershipEdit.canGrantRole}" 
	process="selectRole" 
	update="selectRole,assignedRolesList,sysUserEditForm:sysUserEditGrowler" >
	<f:param name="cid"
		value="#{javax.enterprise.context.conversation.id}" />
</p:commandButton>
And the generated JS is:

Code: Select all

<button id="sysUserEditForm:tabPanelSysUserInfo:cmdRoleGrant" 
	name="sysUserEditForm:tabPanelSysUserInfo:cmdRoleGrant" 
	class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
	onclick="PrimeFaces.ab({s:'sysUserEditForm:tabPanelSysUserInfo:cmdRoleGrant',f:'sysUserEditForm',
	p:'sysUserEditForm:tabPanelSysUserInfo:selectRole',
	u:'sysUserEditForm:tabPanelSysUserInfo:selectRole sysUserEditForm:tabPanelSysUserInfo:assignedRolesList sysUserEditForm:sysUserEditGrowler',
	pa:[{name:'cid',value:'1'}]});return false;" 
	type="submit" role="button" aria-disabled="false">
	
	<span class="ui-button-text ui-c">Grant Role</span>

</button>
(I converted the &quote; to ' for readability.)

and the signature of the event method is:

Code: Select all

public void grantRoleListener(javax.faces.event.ActionEvent event) {
I have no idea what's going on. No errors on the server or in the browser console.

Note the "return false;" at the end of the PrimeFaces.ab( declaration. If I remove it, the call works and the code executes, though there is no ajax update to the UI.

Suggestions?
--- --- ---
PF 7.0 | JSF 2.3 | CDI 1.2 | WildFly 18

arnieAustin
Posts: 103
Joined: 14 Feb 2015, 22:35
Location: Austin, TX

15 Feb 2020, 00:49

Wanted to post an addendum:

Below the grant button is a p:selectOneListbox object with the list of assigned roles and a revoke role button. If I click on a row in the list box, the revoke role is enabled and clicking updates the controls as expected.
--- --- ---
PF 7.0 | JSF 2.3 | CDI 1.2 | WildFly 18

Melloware
Posts: 1565
Joined: 22 Apr 2013, 15:48

15 Feb 2020, 15:27

Look at the network traffic of the AJAX call using F12 Network Browser.

And we usually point people to this amazing answer from BalusC whenever someone asks "my action isn't being called":
https://stackoverflow.com/questions/211 ... nput-value
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 7.0.11 / PF Extensions 7.0.3

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: stolp and 4 guests