Disable pencil of RowEditor

UI Components for JSF
Post Reply
farshi114
Posts: 3
Joined: 15 Mar 2013, 17:45

11 Apr 2013, 15:59

I need to disable row Editor in some rows(because of their specific data) I search too much but I can't find a way to do that.

I have two type of rows,rows with status A and rows with status B.

I want to enable pencil for rows A and disable for rows B
primFaces 3.5+jsf 2+GlassFish 3.1.2

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

11 Apr 2013, 16:07

I don't think you can easily disable it but the rowEditor component does have the rendered attribute, try using that. If it causing a row based rendering according to a row based criteria then you will have pencils only in those rows which can be edited which pretty much follows common practice of only exposing controls when they can be used.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

farshi114
Posts: 3
Joined: 15 Mar 2013, 17:45

11 Apr 2013, 16:32

i tried this code but it didn't work:
<p:column rendered="#{contract.status != "done"}">
<p:rowEditor />
</p:column>
(actualy 'B',is "Done")
Error is this:
javax.servlet.ServletException: Error Parsing /contract/index.xhtml: Error Traced[line: 250] Element type "p:column" must be followed by either attribute specifications, ">" or "/>".
Last edited by farshi114 on 11 Apr 2013, 17:29, edited 2 times in total.
primFaces 3.5+jsf 2+GlassFish 3.1.2

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

11 Apr 2013, 16:48

farshi114 wrote:i tried this code but it didn't work:
<p:column rendered="#{contract.status != "done"}">
<p:rowEditor />
</p:column>
(actualy 'B',is "Done")
Error is this:
javax.servlet.ServletException: Error Parsing /contract/index.xhtml: Error Traced[line: 250] Element type "p:column" must be followed by either attribute specifications, ">" or "/>".
Well your EL is wrong, use (note the use of code tags here)

Code: Select all

rendered="#{'done' ne contract.status}"
You have "done" quoted incorrectly which is what is causing the error.
Secondly you do not want to provisionally render the column because you can't.
You do this with the rowEditor component, like this

Code: Select all

<p:rowEditor rendered="#{'done' ne contract.status}"/>
Tip: rather than exposing such logic as an EL like this use your controller to determine this using a method....

Code: Select all

public boolean getRenderContractEditor(Contract contract) {
    return !"done'.equals(contract.getStatus());
}
and use it as follows

Code: Select all

<p:rowEditor rendered="#{contractController.renderContractEditor(contract)}"/>
The advantages with this approach are many

- You only need to implement this logic in one place but use the result of the method call in many places (satisfies the DRY principle)
- Places the responsibility for this with the contract controller where it belongs (Satisfies the S in SOLID)

There are others as well.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

farshi114
Posts: 3
Joined: 15 Mar 2013, 17:45

11 Apr 2013, 17:32

thanks...it's work
primFaces 3.5+jsf 2+GlassFish 3.1.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests