2

When the checkbox is selected, the corresponding input text should be enabled. But the permit property is not set, nor updateRoles listener is called. I get no exceptions, no indication of something going wrong. I am using PrimeFaces 3.4, Mojarra 2.0.8.

<p:dataTable id="databases" var="database" value="#{mssqlAccDBAccess.databases}"
    sortBy="#{database.name}" resizableColumns="false">
    <p:column headerText="#{label.mssqlDatabasePermission}">
        <p:selectBooleanCheckbox value="#{database.permit}"
            disabled="#{not enabled}">              
            <p:ajax listener="#{mssqlAccDBAccess.updateRoles}" update="user" />
            <f:attribute name="selectedRecord" value="#{database}" />
        </p:selectBooleanCheckbox>
    </p:column> 
    <p:column headerText="#{label.mssqlDatabaseName}"
        sortBy="#{database.name}">
        <h:outputText value="#{database.name}" />
    </p:column>
    <p:column headerText="#{label.mssqlDatabaseUser}">
        <p:inputText id="user" disabled="#{not database.permit or not enabled}"
            value="#{database.user}">       
        </p:inputText>
    </p:column>
</p:dataTable>

Edit 1

The updateRoles method look like this:

public void updateRoles(AjaxBehaviorEvent event) {  
    SelectBooleanCheckbox permit = (SelectBooleanCheckbox) event.getComponent();
    boolean checked = (Boolean) permit.getValue();
    if (checked) {
        Database database = (Database) permit.getAttributes().get("selectedRecord");
        showRoles(database.getRoles());         
    } else {
        hideRoles();
    }       
}

I've added <f:attribute name="selectedRecord" value="#{database}" />. It was not present there because I didn't consider it relevant.

Seitaridis
  • 4,459
  • 9
  • 53
  • 85
  • try to remove `disabled="#{not enabled}"` what is that `enabled` ? isn't it supposed to be some managed bean property ? – Daniel Oct 03 '12 at 07:47
  • enabled is boolean value passed as a ui:param. This facelet is included in another JSF page. – Seitaridis Oct 03 '12 at 07:56
  • have you checked that `` shows the expected value ? also what scope is your `mssqlAccDBAccess` bean in ? – Daniel Oct 03 '12 at 08:01
  • The `h:outputText` displays a **true** value. `mssqlAccDBAccess` is a session scoped managed bean. – Seitaridis Oct 03 '12 at 08:07
  • if you change `update="user"` into `update="databases"` ? – Daniel Oct 03 '12 at 08:11
  • is inside a form ? do you see any errors in server / client consoles? – Daniel Oct 03 '12 at 08:17
  • I have posted in a previous post(http://stackoverflow.com/questions/12688674/determine-absolute-id) information about the way the views are composed. This is also an editor that uses the same views. There is a form in the accounts.xhtml. I get no errors in the browser console or Tomcat logs. – Seitaridis Oct 03 '12 at 08:22
  • 1
    In your place I would simplify this by wrapping the table with form and accessing this xhtml directly , than I would add stuff to see what causing this strange behavior... – Daniel Oct 03 '12 at 08:29
  • @Seitaridis 1, could you put the implementation snippet of your listener method here and also explicitly specify a listener event – kolossus Oct 04 '12 at 04:35
  • For input components the default client side event is *onchange*. What should I put instead? – Seitaridis Oct 04 '12 at 05:51

0 Answers0