Spring Webflow

americano0309
Member
Inscription: 08 March 2017

Spring Webflow

Post By americano0309 » 08 March 2017, 08:50

I'm new to spring webflow, and I'm trying to put CSV into practice. I'm going to need opinions from everyone whom'd like to contribute.

In the add.xhtml, I would like several fields to disappear/remainonce I click either news or announcement radio button. And upon clicking save, it should dump all the entered details into db.

The thing is, it doesn't work at all.

The rendering should take place once I chose either news or announcement right?

Please advise, I'd like to learn what I'm missing. Thank you in advance.


flow.xml
<var name="main" class="com.web.mnt.mnt.ann.AnnBean" />
    <!-- I already note AnnBean as main -->
<view-state id="main" view="main.xhtml">
    <on-entry>
        <set name="viewScope.action" value="'add'" />
    </on-entry>
    <transition on="save" to="main" />
    <transition on="cancel" to="main" />
</view-state>
<h:form id="addAnn" enctype="multipart/form-data">
    <!-- Item no 1-->
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="3">
        <p:outputLabel value="Message Type  *" /><p:spacer width="10"/>
        <p:selectOneRadio id="messageType" value="#{main.MESSAGE_TYPE}" required="true">

            <f:selectItem itemLabel="News and Announcement" itemValue="NewsAndAnnouncement"/>
            <f:selectItem itemLabel="Broadcast" itemValue="Broadcast" />
            <p:ajax process="messageType" update="@form"/>
        </p:selectOneRadio>
    </h:panelGrid>

    <!-- Item no 2-->
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="3">
        <p:outputLabel value="Language  *" /><p:spacer width="10"/>
        <p:selectOneRadio id="language" value="#{main.LANGUAGE}" required="true">
        <f:selectItem itemLabel="Bahasa Melayu" itemValue="Bahasa Melayu" />
        <f:selectItem itemLabel="English" itemValue="English"/>
        </p:selectOneRadio>
    </h:panelGrid>

    <!-- Item no 3-->
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="3">
        <p:outputLabel value="Broadcast Message *" rendered="#{main.MESSAGE_TYPE eq Broadcast}"/><p:spacer width="10"/>
        <p:inputText style="width: 300px;" value="#{main.SUBJECT}" rendered="#{main.MESSAGE_TYPE eq Broadcast}" required="true"/>
    </h:panelGrid>

    <!-- Item no 4 -->
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="3">
        <p:outputLabel value="Subject   *" rendered="#{main.MESSAGE_TYPE eq NewsAndAnnouncement}" /><p:spacer width="10"/>
        <p:inputText style="width: 300px;" value="#{main.SUBJECT}" />
    </h:panelGrid>

    <!-- Item no 5-->
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="3">
        <p:outputLabel value="Content   *" /><p:spacer width="10"/>
        <p:inputTextarea rows="6" value="#{main.CONTENT}" style="width: 300px;" />
    </h:panelGrid>

    <!-- Item no 6-->
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
        <p:outputLabel value="Image     "></p:outputLabel>
            <p:fileUpload fileUploadListener="#{main.doUpload}" mode="advanced" dragDropSupport="false" update="messages"
                sizeLimit="100000" fileLimit="3" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
            <p:growl id="messages" showDetail="true" />
    </h:panelGrid>

    <!-- Item no7-->
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5"> 
        <p:outputLabel value="File Attachment       " /> <p:spacer width="10"></p:spacer>
            <p:growl id="messages2" showDetail="true" />
            <p:fileUpload value="#{main.doUpload.FILE}" mode="simple" skinSimple="true"/>
            <p:commandButton value="Submit" ajax="false" actionListener="#{main.doUpload}" disabled="true" />
    </h:panelGrid>

    <!--  Item no 8-->
    <h:panelGrid >
        <p:outputLabel for="date" value="Start Date :" />
        <p:calendar id="date" value="#{main.START_DATE}" showOn="button"/>
        <p:outputLabel for="edate" value="End Date :" />
        <p:calendar id="edate" value="#{main.END_DATE}" showOn="button" />
    </h:panelGrid> 

        <!-- Item no 9-->
    <h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="3">
        <p:outputLabel value="Status :" />
        <p:selectOneRadio value="#{main.STATUS}">
            <f:selectItem itemLabel="Active" itemValue="active" />
            <f:selectItem itemLabel="Inactive" itemValue="inactive" />
        </p:selectOneRadio>
    </h:panelGrid>

    <!-- Buttons-->
        <p:column headerText="Action" exportable="false" width="150">
            <!--Save Button -->
            <p:commandButton value="#{msg['common.btn.save']}"
                icon="ui-icon-save" update="@form" action="#{annBean.doSubmit}" />
            <!--Delete Button -->
            <p:commandButton value="#{msg['common.btn.delete']}" update="@form"
                action="delete"></p:commandButton>

            <!--Cancel Button -->
            <p:commandButton value="#{msg['common.btn.cancel']}" update="@form"
                action="cancel">
            </p:commandButton>