Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to conditionaly populate a column in the datatable based on another column

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a datatable with input fields and 8 rows.
If any of the stylenumbers in a row is entered, then the qty column should be entered and it should be greater than 0.
Only for the rows where style number is entered. Can i use some kind of validation/rendering to make this happen?
Appreciate your help!

<p:dataTable value="#{invBean.orderList}" var="order" rows="8" rowStyleClass="#{data.id mod 2 == 0 ? null : 'odd'}">
styleClass="formStyle"
cellspacing="0"
cellpadding="0"
border="0"
rowClasses="odd,even"
columnClasses="Style Number,Color,Quantity"
class = "orderData">

<p:column headerstyleClass="first">
<f:facet name="header">
<h:outputText value="Style Number" align="left" class="title1"/>
</f:facet>
<h:inputText id = "styleNo" value="#{order.styleNumber}" align="left" class="title1" >
<f:validator binding="#{styleValidator}" />
</h:inputText>

</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Color" align="left" class="title1"/>
</f:facet>
<h:inputText value="#{order.color}" class="title1"/>
</p:column>
<p:column headerstyleClass="last">
<f:facet name="header">
<h:outputText value="Quantity" align="left" class="title1"/>
</f:facet>
<h:inputText value="#{order.qty}" class="title1" />

</p:column>
</p:dataTable>
 
Saloon Keeper
Posts: 22480
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Anitha!

You can make your sample code and XML much easier to read: https://coderanch.com/how-to/java/UseCodeTags

The critical thing to keep in mind is that JSF is based on Model/View/Controller. So to update the display, you must update the model. That is, you must update the appropriate properties in the backing bean. In the case of a dataTable, the table's DataModel object is a sub-model, and the individual rows of that table are components of that sub-model, so that's where the updates must be made.

Under stock JSF, the updates could only be done by submitting the entire form containing the table and getting an updated page back. You are using PrimeFaces, I see, so if you prefer, you could take advantage of the PrimeFaces AJAX support features to update parts of the current page instead of submitting and updating the entire page. The technical name for that process is "partial page update" or "partial page refresh".

 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic