Grails: avoid browser checks when click on button - validation

In my Grails project, I would like to use a button to jump on another page while I'm in creation of an entity.
Here is the code for the button:
<button href="${createLink(controller: 'myController', action: 'create')}">
The problem is that, clicking on that button, if I'm in creation of some entity, it performs checks on form (I see a popup below a field telling me that I need to select an element from dropdown)
How can I jump to create of another entity while I am creating / modifying another one?

Try using an anchor tag instead of a button:
Some other create page

Related

How to pass data from one page model to another page model in fresh mvmm

I have used Fresh MVMM. I need to pass a data from one page model to another page model without using init and reverse init.
Eg: I have one toggle button in first content page.
I need to toggled the button based on the selection in second popup page without popup the second PopPopupPageModel.
ReverseInit is worked when popup the second PopPopupPageModel and can easily pass data.
But I need to toogled the button in first page without popup the second page.
Please help...

Display thymeleaf fragment on checkbox click or checked

I have form which has some checkbox. I want to display a fragment when I user click (checked) on checkbox.
Is there a way in Thymeleaf by using any th:* function or how Can I display fragment in thymeleaf on checkbox click.
There are two ways to solve your requirements...
Create a simple JavaScript handler on checkbox click event and submit your form with some parameter/hidden value. When the server handles "onSubmit" request, check this value and if chackbox was chacked, render view (Thymeleaf template) with included additional fragment. Vise versa when checkbox is unchecked render view without this fragment. This solution is not ideal as your server will get hits every time the user checks ckeckbox.
Always render the view with the fragment included into the page. By default hide top-level fragment element with style display:none;. create a simple JavaScript handler on checkbox click event and toggle this style from none to block and vise-versa. This solution works completely in the user's browser and doesn't require to submit to your server.

refresh msflexgrid from another form

Working on some old code at the moment and a bit stuck
I have a main form that has a msflexgrid populated with data from SQL and on this form there is a button, which opens a modal form that allows me to enter data and save it to SQL (then closes the form).
The issue is the msflexgrid on the main form doesn't refresh after I save data from the modal, I need a way of automatically refreshing the msflexgrid after the modal form closes.
Any help would be appreciated :)
Maintain a global structure and update it when the changes are committed in the modal form. After modal form is unloaded, control comes back to the command button click event in main form and there, you update the msflexgrid with the data available in the global structure. Like this, explicitly we need to update the msflexgrid and it is not refreshed automatically.
It just hit me that because the second form is a modal form it only return to the main form when the second form unloads, so I can just add the refresh function right after showing the second form, I knew I was doing something stupid :/
Dim AddBusContact As New frmAddBusContact
AddBusContact.SetBusID (clsThisForm.BusID)
AddBusContact.Show (vbModal) 'code stops here until second form is unloaded
refreshgrid 'and I can just call the function that refreshes the grid here
I would suggest one more idea. If the modal form allows the user to cancel action, or to give up what started to do, probably it is better to trigger the grid refresh function before the modal form unloads and only if changes have been made...

How to preserve bootstrap dropdown state on Meteor

I have a bootstrap dropdown button for each table row.
When the dropdown is clicked it shows a small form with some input fields.
When the user submits this form data or the row gets redrawn the dropdown closes.
I tried preserving the dropdown state using the Template.preserve() method, similar to inputs but with no success.
Some suggested using {{#constant}} directive surrounding the dropdown I also have some reactive content inside the form that needs re-rendering, so this options is not for me.
I have noticed this issue with reactive templates and there is no good solution that I know of. This is somewhat of a hack but it works.
Option 1
Manually add and remove a css class to your dropdown. Use session variables to save the state of the dropdown.
This should be the default state of your dropdown... class="dropdown"
When a user clicks on the dropdown use a session variable to save its state and add 'open' to the HTML class attribute. class="dropdown open"
When a user closes the dropdown remove 'open'
Option 2:
1. User clicks dropdown button.
2. Save dropdown button ID as active using a session variable.
3. Use the following callback to reopen your dropdown... Template.myTemplate.rendered = function ( ) {
if (dropdown = active) {
$().dropdown('toggle'); //instead of toggle try 'open'
}
}
I haven't tried this with dropdowns yet but I was having the same issue with modals disappearing every time the template kept rendering. I tried the second option and it didn't work that great. I ended up using something like the first option to solve the issue and it worked great.

Custom "Next" Buttons for Spring MVC AbstractWizardFormController

Currently, a spring application I am working on has several wizards that it is using with Spring's AbstractWizardFormController. During the early stages of development(pre-design phase), the type of "next" button did not matter.
Just to refresh, the Next and Back button are submit buttons with target attributes. So a next button on the first page of a wizard would look like the following.
<input type="submit" name="_target1" value="Next"/>
This is the standard way Spring does wizards on the view. This works fine, given that you want your Next button to be a standard HTML submit button. Otherwise, in my case, If I want a custom button, I am not sure how to do this. I know it is possible, but haven't found any documentation.
I imagine I will need to do a javascript submit, but I am not sure how to set the name of the button, of if something else needs to be done.
I just need to know how I can still extend AbstractWizardFormController, and use custom buttons.
When clicked, HTML submit button submits a form with additional parameter {name}={value}, that is _target1=Next. I guess the value doesn't matter here, controller looks at the name. So, if you want to emulate this with Javascript, you may, for example, dynamically add a hidden field with name = "_target1" before submit.

Resources