How to validate that each with required=”true” is filled out?

So i have this JSF code that will show a column of datatable and each of column must be filled. I also put the rowEdit button in the right side. so before the user fill the data, they must click the rowEdit button on the right side. This is the code :

<p:panel header="Form Data">
    <p:panelGrid columns="1">
        <div class="grid-flex-column">
            <div class="col">
                <div class="box">
                    <div class="field-grid">
                        <h:outputLabel value="Fullname:" />
                        <h:outputLabel value="NIK:" />
                        <h:outputLabel value="Departement:" />
                        <h:outputLabel value="Division:" />
                        <h:outputLabel value="Position:" />
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="box">
                    <p:commandButton value="Add Column" action="#{dtStrukView.onAddNew()}"
                                                     update="form" styleClass="ui-button-outlined" />
                </div>
            </div>
            <div class="col">
                <div class="box">
                    <p:growl id="msgs" showDetail="true"/>
                    <p:dataTable value="#{dtStrukView.strukPembayaranList}" var="struk" editable="true">
                        <p:ajax event="rowEdit" listener="#{dtStrukView.onRowEdit}" update=":form:msgs"/>
                        <p:ajax event="rowEditCancel" listener="#{dtStrukView.onRowCancel}" update=":form:msgs"/>
                        <p:column headerText="Keterangan">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{struk.keterangan}" required="true" />
                                </f:facet>
                                <f:facet name="input">
                                    <h:inputText value="#{struk.keterangan}" required="true" />
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="Tanggal Kuitansi">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{struk.tanggalKuitansi}" required="true" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:datePicker value="#{struk.tanggalKuitansi}" monthNavigator="true" pattern="dd/MM/yyyy" required="true"/>
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="Jumlah">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <h:outputText value="#{struk.jumlah}" required="true" />
                                </f:facet>
                                <f:facet name="input">
                                    <h:inputText value="#{struk.jumlah}" required="true" />
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column headerText="Upload Tanda Tangan">
                            <p:cellEditor>
                                <f:facet name="output">
                                    <p:fileUpload id="uploader1" mode="simple" skinSimple="true" styleClass="block mb-5"
                                                                                      title="my custom title" accept=".jpg,.jpeg,.png" />
                                </f:facet>
                                <f:facet name="input">
                                    <p:fileUpload id="uploader2" mode="simple" skinSimple="true" styleClass="block mb-5"
                                                                                     title="my custom title" accept=".jpg,.jpeg,.png" />
                                </f:facet>
                            </p:cellEditor>
                        </p:column>
                        <p:column style="width:6rem">
                            <p:rowEditor editTitle="Edit Row" cancelTitle="Cancel Edit" saveTitle="Save Row"/>
                        </p:column>
                    </p:dataTable>
                </div>
            </div>
        </div>
    </p:panelGrid>
    <div class="grid justify-content-end">
        <div class="col-4" >
            <div class="box" style="padding-left: 90%">
                <p:commandButton value="Save Data" update="form" action="#{dtStrukView.save}" icon="pi pi-check" validateClient="true" />
            </div>
        </div>
    </div>
</p:panel>

When user click “Add Column” on the top, there will be add more column shows in the bottom and each of column have the rowEdit button to user fill the data. When user click the rowEdit button, each column will editable and must be required to fill. When there’s one column that not filled, notification will show up and tell the user to fill that column. How to make the column required to fill and show the message that we custom?

New contributor

Diti Merita is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

The <h:outputText> doesn’t support the required attribute. It’s only supported on UIInput components.

Just add a <h:inputHidden ... required="true"> to each <f:facet name="output"> along the <h:outputText>.

E.g.

<p:cellEditor>
    <f:facet name="output">
        <h:outputText value="#{struk.keterangan}" />
        <h:inputHidden value="#{struk.keterangan}" required="true" />
    </f:facet>
    <f:facet name="input">
        <h:inputText value="#{struk.keterangan}" required="true" />
    </f:facet>
</p:cellEditor>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật