How to correctly close container-dialog after submit when rendering a file - moqui

I have a dialog in which user picks a record. After submitting, the transition runs a service, which loads data and then renders an output file.
<transition name="exportActiveBatch_LinkId" read-only="true">
<actions>
<service-call name="mantle.ledger.LedgerLoadingServices.runLinkId#Export" in-map="context+[batchId:batchIdPicker]" out-map="context" ignore-error="false"/>
<if condition="hasError==true">
<!--<message error="true">Error occurred '${errorMessage}'!</message>-->
<log message="Error occurred '${errorMessage}'!" level="error"/>
<else>
<!--<message error="false">Export successful.</message>-->
<log message="Export successful." level="info"/>
</else>
</if>
</actions>
<default-response type="none"/>
<error-response url="."/>
</transition>
Everything works fine, data is loaded correctly, screen is rendered and output file is generated. The problem is, that the dialog does not close and remains in modal.
I would expect the dialog to close, but that does not happen. How shall I treat the transition responses correctly?

Normally container-dialog dialogs don't close automatically when a form in them is submitted, there can be multiple forms or for other reasons you don't want this. Most of the time you wouldn't notice it because when a form is submitted a new page is loaded.
A user can easily close the dialog by clicking outside it or on the 'x', but you could also add some JavaScript to do this if you want it done automatically. These are standard Bootstrap dialogs so you can use the documentation on getbootstrap.com as a reference.

Related

unable to identify tooltip message present for the textboxes in selenium

i am trying to automate the login functionality of a site.I want to verify whether the tooltip is present or not and to capture the tooltip text displayed for the textboxes.The tooltip is displayed when trying to click on the login btn without filling the textboxes.The tooltip text is attached to the input elements via bootstrap javascript.No tilte attribute is present for the textboxes
https://elasticbox.com/login/ is the site address.Any ideas on how to capture the tooltip text .Thanks in advance
This is not a bootstrap tool-tip as you commented for #Varun's reply.
This is just the HTML5 form validation which comes into action when you put "required" as the attribute of textfield.
Make an html file 'test.html' file using the below code:
<html>
<body>
<form name='form1' post="http://www.google.com">
<input type='email' required placeholder='email address please' />
<input type='password' required placeholder='password please' />
<input type='submit' value='button1' />
</form>
</body>
</html>
Herein, when you click on "button1" (after opening the file in browsers like: Chrome, Firefox, etc.), you will see the necessary validation under the textfield(s).
But, there is no possible way to inspect them.
You can, however, use Sikuli/Autoit to check the presence of that validation text, but that again will be a lost cause as the image of the validation messages/tooltip differs from one browser to another.
Looks like developer needs to be consulted for this.
In javascript it seems like the signin button will remain disabled until both values are filled i.e. username and password.
I am not much into javascript, may be you can consult the developer in order to understand this more.
You can refer image below:

Transitions between Screens in MOqui

I have been looking for transitions between screens but was unable to find the best practice to navigate through screens .Making sub screens and entry in apps.xml was a try but it gives a link on the top of the page which is not what I want . I want make transitions as we make in html-5 or earlier versions through anchor tag. What is the best practice to do the same?
Below code in a screen can generate the code you want. But you would need to override the "label" macro by yourself to let it contain a "link" that is simply done by add a <#recurse/> in macro "label".
<transition name="gotoScreen1">
<default-response url="Screen1"/>
</transition>
<widget>
<label type="pre">
<link url="gotoScreen1" link-type="anchor" text="This test link from FTL"/>
<label type="pre">
</widget>
A screen transition is a part of a screen definition that specifies how to process input to the transition (if there are logic/actions associated with it) and which screen to transition to when it is complete.
To access a screen transition you just have the browser (or client) go to the URL of the screen, plus the name of the transition separated by a forward slash (i.e. in the URL treat the transition as a directory or file within the "directory" of the screen). This can be done with a hyperlink, a form target, an AJAX call, etc.
To create a link or button using the XML Screen (or XML Form) in Moqui, just use the "link" tag.

Work around to POST requirement

I need to be able give users a link to my site with a parameter that will control their experience on the destination page, but, of course, Moqui does not allow parameters to be passed as a GET transaction. What are ways that I can work around that? It needs to be something that can be sent in an email, via sms and audibly.
An error message would be helpful know exactly what you are running into, but it sounds like the constraint to mitigate XSRF attacks.
The error message for this situation explains the issue and the recommended solution: "Cannot run screen transition with actions from non-secure request or with URL parameters for security reasons (they are not encrypted and need to be for data protection and source validation). Change the link this came from to be a form with hidden input fields instead."
You can pass URL parameters to screens to be used in code that prepares data for presentation, but not to transitions for code that processes input. The solution is to use a hidden form with a link or button to submit the form (that can be styled as a link or button or however you want). This is slightly more HTML than a plain hyperlink with URL parameters, but not a lot more and there are examples in various places in the Moqui itself.
If you are using an XML Screen/Form you can use the link element to do this with the #link-type attribute set to "hidden-form" or "hidden-form-link" (which just uses a hyperlink styled widget instead of a button styled one). If the #link-type attribute is set to "auto" (which is the default) it will use a hidden-form automatically if link goes to a transition with actions.
In plain HTML one possible approach looks something like this:
<button type="submit" form="UserGroupMemberList_removeLink_0">Remove</button>
<form method="post" action=".../EditUserGroups/removeGroup" name="UserGroupMemberList_removeLink_0">
<input type="hidden" name="partyId" value="EX_JOHN_DOE">
<input type="hidden" name="userGroupId" value="ADMIN">
</form>
Note that the button element refers to the form to submit, so can be placed anywhere in the HTML file and the form element can be placed at the end or anywhere that is out of the way (to avoid issues with nested forms which are not allowed in HTML).

Drag and drop file upload strange behaviour

I'm using Primefaces 3.5 and I have ran into a pretty disturbing problem. The component looks like this in the xhtml:
<p:tab id="installApp" title="Install application">
<h:form enctype="multipart/form-data">
<p:panel header="Upload status" id="upld_status">
<p:dataTable id="errorTable" var="error"
value="#{applicationInstallerBean.uploadMsgs}">
<p:column headerText="Application">
<h:outputText value="#{error.filename}" />
</p:column>
<p:column headerText="Status">
<h:outputText value="#{error.errorMsg}" />
</p:column>
</p:dataTable>
</p:panel>
<p:remoteCommand name="clearPrevious" update="upld_status uploader" action="#{applicationInstallerBean.clearPrevious}" process="#this" />
<p:fileUpload id="uploader" multiple="true" dragDropSupport="true" onstart="clearPrevious()"
fileUploadListener="#{applicationInstallerBean.install}" uploadLabel="Install"
mode="advanced" update="#this upld_status" auto="false"
allowTypes="/(\.|\/)(zip)$/" styleClass="install_app_fileupload" />
</h:form>
<p:panel header="Help" toggleable="true">
<ui:include src="applicationInstallHelp.xhtml" />
</p:panel>
</p:tab>
Now the behaviour I'm experiencing is pretty strange:
For the first few times, uploading files with drag'n'drop method works fine. After a few uploads, the following errors appear totally undetermenistic:
FileUpload component disappears after pressing Upload button, only to reappear when I refresh the page
the onstart method gets called a lot of times during upload
the table containing the status of the upload does not refresh or only one of the files appear there, when multiple are uploaded
I also get a message from the browser that a script is running on this page and I can abort or continue
What I have tried:
Removing the h:form element, since this is an include in the index file, which already has a h:form element in it
Result: basicly the same, with the difference, that dropping a file for the first time onto the component automatically uploads it, but auto is set to false
I have also tried emptying the browser cache, redeploying the application from a scratch, turning off multiple...all with no luck.
The files I'm uploading are 80k to 9mb.
From this it looks to me, that uploading too much files makes the whole thing go crazy, but I cannot really think of a solution. Any help would be appreciated.
Update: During testing I found that the onstart method ALWAYS fires more than once after the first upload. For the first time it only fires once. On the second upload about 7-10 times, on the third time it seems it keeps firing until I end the session. This is pretty strange and I think it may be the root of the problems. Any ideas on this?
Thank you in advance!

PrimeFaces FileUpload: how many files are selected?

The "multiple files" feature enables to select more files for uploading. The listener is called after each transmission. But I don't know how many files will be uploaded by the component at all.
I would like to navigate to the next page after all the selected files were processed. Any suggestion is highly appreciated.
fileUploadListener="#{uploadBean.handleFileUpload}"
maybe not a good solution but you can use the oncomplete from p:fileUpload to trigger a hidden button, which invokes a action to navigate.
<p:fileUpload ... oncomplete="$('#btn').click()" />
and
<p:commandButton id="btn" action="#{myBean.actionToNavigate}" style="display:none;" />