0

I'm using bootstrap modal to show the selected list of data. How can I show the modal when the list in managed bean is not empty.

My modal is

                 <div id="modalPanel-1" data-backdrop="static" class="modal hide fade in">
                                <div class="modal-header"><a data-dismiss="modal" class="close" id="closeModal" onclick="reconstruct()">×</a>
                                    <h3>Selected Trips</h3></div>
                                <div class="modal-body" style="width: 100%;">
                                    <p:panel style="border: medium none;" id="modalPanel-1-panel">
                                        <h:form id="modalForm">
                                            <h:selectOneMenu style="width:25%;"
                                                             value="#{userAction.assignVehicleSelectedVehicleID}">
                                                <f:selectItem itemLabel="Select Vehicle"></f:selectItem>
                                                <f:selectItems value="#{userAction.allVehicleList}"></f:selectItems>
                                                <p:ajax listener="#{userAction.assignVehicleChangeHandler}"
                                                        process="@this" update="@form"/>
                                            </h:selectOneMenu>
                                            <h:selectOneMenu id="driver" style="width:25%; margin-left: 10px;"
                                                             value="#{userAction.assignVehicleSelectedDriverID}">
                                                <f:selectItem itemLabel="Select Driver"></f:selectItem>
                                                <f:selectItems value="#{userAction.drivername}"/>
                                            </h:selectOneMenu>
                                            <h:commandButton
                                                    styleClass="btn btn-success" value="New Ride"
                                                    style="margin-left: 20px; margin-top: -10px;">
                                                <p:ajax listener="#{userAction.linkVehicleForAssignVehicle}"
                                                        process="@form" update="@form, :treeTableForm" oncomplete="clearModalErr();"></p:ajax>
                                            </h:commandButton>                                               
                                            <div>
                                                <ul></ul>
                                            </div>
                                            <p:dataTable value="#{userAction.selectedMatchedTripDTOs}" var="trip"
                                                         rendered="true" expandedRow="true">
                                                <p:column headerText="Group ID">
                                                    <h:outputText value="#{trip.groupId}"></h:outputText>
                                                </p:column>
                                                <p:column headerText="Route">
                                                    <h:outputText value="#{trip.route}"></h:outputText>
                                                </p:column>
                                                <p:column headerText="Requester">
                                                    <h:outputText value="#{trip.userName}"></h:outputText>
                                                </p:column>
                                                <p:column headerText="Count">
                                                    <h:outputText value="#{trip.count}"></h:outputText>
                                                </p:column>
                                                <p:column headerText="Ride ID">
                                                    <h:outputText value="#{trip.rideId}"></h:outputText>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Action</f:facet>
                                                    <h:commandLink rendered="true" disabled="false">
                                                        <i class="fa fa-trash" title="Delete"></i>
                                                        <p:ajax listener="#{userAction.removeTripFromSelectedList(trip)}"
                                                                update=":modalForm"/>
                                                    </h:commandLink>
                                                </p:column>
                                                <p:rowExpansion>
                                                    <ul><h:outputText value="#{trip.startDate}"
                                                                      style="color: darkblue; font-size: 16px; padding-left: 400px;"/>
                                                    </ul>                                                    
                                                    <pm:content rendered="#{not empty trip.custom}">
                                                        <ul style="width: 100%;"><h:outputText value="Notes"
                                                                                               style="font-size: 14px"
                                                                                               rendered="#{not empty trip.custom}"/>&nbsp;<h:outputText
                                                                rendered="#{not empty trip.custom}"
                                                                value="#{trip.custom}"
                                                                style="color: #999999; font-size: 14px; "/></ul>
                                                    </pm:content>
                                                </p:rowExpansion>
                                            </p:dataTable>
                                        </h:form>
                                    </p:panel>
                                </div>
                            </div>

Can I enclose the modal in something like this?

<pm:content rendered="#{not empty trip.customList}"> </pm:content>

Or can I trigger the modal when something is added to the list in managed bean.

Please help me out.

Chethan
  • 501
  • 1
  • 8
  • 15

1 Answers1

0

if you want to hide a modal in js you use bootstrap's hide syntax

if (data.length > 0) {
   $('#modalPanel-1').modal('hide');
}
madalinivascu
  • 32,064
  • 4
  • 39
  • 55