0

I want to execute a method from backing bean on onComplete attribute of p:fileUpload because I am processing some inputText values on upload action and I want those values to be added to the file in another method on the same upload click, here I don't want to use another button action.

So I am using p:remoteCommand to call the method from bean using the above javascript code. Here I'm calling javascript function on onComplete of p:fileUpload and the script calling the p:remoteCommand which in turn calling the insertProperty() method.But the insertProperty() is not getting called. How is this caused and how can I solve it? Thanks in advance.

The javascript is

<script type="text/javascript">
                        function addProperties(){                           
                            lazyload();    
                        }                        
       </script>

</h:head>

My code is `

<h:body>

    <h:form id="mainformId"
        style="background: #A9CEEA !important;margin-top:5px !important;">

        <div>
            <h:form id="uploadformId">
             <p:messages id="msg"/>
             <p:remoteCommand name="lazyload"   process="@this"
                                     actionListener="#{hubDocsBean.insertProperty}" >
                    </p:remoteCommand>
                <p:panelGrid style="width:100%;">
                    <p:row>
                        <p:column colspan="4">
                            <p:fileUpload fileUploadListener="#{hubDocsBean.fileUpload}"
                                dragDropSupport="false" 
                                allowTypes="/(\.|\/)(txt|doc|docx|xls|xlsx|pdf)$/" 
                                update=":mainformId:tableformId:docTableId, msg" multiple="false"
                                process="IagencyId,ImarketId,IvendorId,IstationId" mode="advanced" sizeLimit="52428800" oncomplete="addProperties();" />

                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column>
                            <h:outputText value="Agency" />
                            <p:spacer width="5"></p:spacer>
                            <p:inputText value="#{hubDocsBean.inputagency}" id="IagencyId" />

                        </p:column>

                        <p:column>
                            <h:outputText value="Market" />
                            <p:spacer width="5"></p:spacer>
                            <p:inputText value="#{hubDocsBean.inputmarket}" id="ImarketId" />

                        </p:column>

                        <p:column>
                            <h:outputText value="Vendor" />
                            <p:spacer width="5"></p:spacer>
                            <p:inputText value="#{hubDocsBean.inputvendor}" id="IvendorId" />


                        </p:column>
                        <p:column>
                            <h:outputText value="Station" />
                            <p:spacer width="5"></p:spacer>
                            <p:inputText value="#{hubDocsBean.inputstation}" id="IstationId" />

                        </p:column>
                    </p:row>`
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

-2

By the way, you don't need to have the extra Javascript. You can just use:

oncomplete="lazyload()"

instead of

oncomplete="addProperties();"

Daniel Maldonado
  • 314
  • 4
  • 19
  • This might be a simplified example... And this is not an answer to the question, but rather a comment – Kukeltje Jul 30 '15 at 15:13