java - How to implement some if-then logic with JSF and Facelets? -


I have a bean with the field status . Depending on the status the values ​​should be applied to present the different CSS class.

Therefore, I need something like this (pseudocode from very real things):

  if condition == "approved" cssClass = "green" == "Disapproved" cssClass = "red" & lt; Span class = "cssclass" & gt; Some information & lt; / Span & gt; I tried to implement  jstl  but I can not work with Facelats and JSF (but I have heard that it is possible, maybe its truth) . Here's the code: 

  & lt; C: select & gt; & Lt; C: when test = "# {report.approved}" & gt; & Lt; C: set var = "statusClass" value = "approved" /> & Lt; / C: When & gt; & Lt; C: when test = "# {report.rejected}" & gt; & Lt; C: set var = "statusClass" value = "disapproved" /> & Lt; / C: When & gt; & Lt; C: when test = "# {report.inprogress}" & gt; & Lt; C: set var = "statusClass" value = "progress" /> & Lt; / C: When & gt; & Lt; C: when test = "# {report.pendingHR}" & gt; & Lt; C: set var = "statusClass" value = "pending" /> & Lt; / C: When & gt; & Lt; / C: Select & gt; & Lt; Span class = "status $ {statusClass}" & gt; # {Report.formattedStatus} & lt; / Span & gt;  

How should this be done with JSF / Facelats?

To give benefit to both sides (model and scene), rather than one of the four independent booleans, Code> enum , which can cause maintenance problems after all.

  Public domain status {Approved, Rejected, Progress, Pending; }  

It's not just that easy and Java is a cleaner to handle, but you can print it in EL.

  & lt; Span class = "# {bean.status}" />  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -