How to append a empty row to a list/table which is bound to a OData(List Binding) in sapui5? - odata

I have have a list/table which is bound to a entitySet from OData Model V2. I have a add(+) button on screen on clicking that button a empty row(s) need to be appended to the list/table. After that if I enter any data that should be saved into the backend on clicking of save button.
This is possible using JSONModel, but I want to use the OData model .
Regards,
Suman Kumar

It does work with two way data binding.
You can do that using odataModel createEntry method.
The createEntry expects a parameter, the path to your entitySet that you want to create (It should be something like XXXXset). Imagine the following:
1 - User clicks an "Add" button that renders a dialog Window with some fields and two buttons (save and cancel) for him to add his brand new entity.
2 - On the "open event" before you open the dialog, you create a new entity with the createEntry method. Its return gives you a context that you can bind to the dialog.
that.contextCursoIniciativaEmpregadoASerCriada = that.getView().getModel().createEntry('/CursoIniciativaEmpregadoSet');
that.fragmentCriacaoDadosInicEmpregado.bindElement(that.contextCursoIniciativaEmpregadoASerCriada.sPath);
that.fragmentCriacaoDadosInicEmpregado.open();
3 - The dialog pops up with the bind in place.
4 - The user fills the dialog with the entities properties
5 - The user clicks on the save button and you submit your changes

Related

Salesforce URL Hacking

I have an object with many record types, and I need to populate some fields on it whenever it is created.
For example, I have an object called "CustomObj" with a field called "CustomF" with these 2 Record Types "RecType1" and "RecType2".
On the creation of a new "CustomObj" I need to populate the field the "CustomF" by "Hello" when the record type is "RecType1"
and by "Bye" when the record type is "RecType2"
Can I do that using the URL Hacking or I have to create 1 visualforce page to select the record type then redirect to the standard page with the values to populate this field or there is another approach?
What is the best practice?
How can I know the RecordType selected from the url itself ?
Thank you.
You can do this by an Workflow Rule. Go to Setup->Create->Workflow & Approvals. Than u can choose your object on which u want to set up the workflows. Most of the part should be straightforward since all the steps are well documented.
So one rule would be like:
If Record Type == RecType1 than fill in Field XY with value ABC
I see.
This is also possible. Go to the object and than your field you want to fill in the value. Click on edit and use the formula editor.
You can use a rule like
IF( $RecordType.DeveloperName = 'RecType1', 'Value for this', '')
for the default value
Salesforce does not provide an option to override "continue" button on record type selection page. but you can override "new" button. So you can do the following
Override "New" button to move to a record type selection page, which
will be a custom vf page (use radio buttons, description etc.).
The submit button (u can name as "Continue", just to imitate) should redirect to the standard page of data entry. But the
URL will be custom made.
You can refer to this Blog (Saurabh's Salesforce Blog) - http://writeforce.blogspot.in/2012/12/prepopulating-fields-using-url-hacking.html - for the idea of how the URL hacking can be done as per your need. Here you need to identify the field id and use them in the URL to provide a value to be prepopulated.

Passing a selected row from a GSP's table to a Controller in Grails 3.0

I have one controller that sends a list of users data (UserID, FirstName, LastName, email) to a GSP.
The GSP displays the data into a table of 5 columns where the 5th column is a submit button so one particular row in the table can be selected. That selected row of data is then passed back to the same controller for further processing.
I am new to Grails 3 and have not found a similar use case.
It seems to me that Grails does not have an equivalent of the JSF dataTable. I need pointers on how to do this without using JavaScript or JQuery.
Thanks in advance.
You can use grails http://grails.github.io/grails-doc/2.2.1/ref/Tags/remoteFunction.html which can be assigned to Dom event to call the remote method. For example If you have a regular button you can add the following code:
onclick="<g:remoteFunction action='modify' id='${user.id}'/>"
Another option to use would be http://grails.github.io/grails-doc/2.3.7/ref/Tags/submitToRemote.html which creates a button that submits the containing form as a remote Ajax call. Here url parameter can be used as per documentation:
url - The url to submit to, either a map contraining keys for the action, controller and id or a string value
Hope this helps.

passing a list of objects from jsf page to another

I am new at JavaServer Faces (JSF).
I have a list of cars and after pressing the commandButton of my first page I want to show the list in the other page (the backing beans are RequestScoped).
I have seen examples where you can only pass String values.
if you have list of cars, it means you have data table or some another list which is coming from managed beans. if you want show whole list in the next page, you need just call the same list from next page.
if you want pass only one row /object, you should pass row/item id via f:param , in the next page from another managed bean you should handle id and call from database getItemById(id) and in the page show item.

Rails 4 Single form-two actions -preview and assign

I have a form which has two buttons
One will assign the form, i mean create an entry in corresponding table after validation and redirect to another page
Second will give a preview of the values submitted on the form.For the preview screen we need some calculations so that an action to be called from controller and respective page will be loaded.
This page should seen on the same form if i clicked preview before assigning the form
How i would address this is to change your new action so that it takes the same params as the create action, and makes the object but doesn't save them. This means that if you call the new action with the params it will reload the form with the built but not saved objects' data displayed in it.
The two buttons will need to change the form's action attribute so that it submits to the create or the new action as appropriate.
This is a general answer, as your question is quite general!

ASP.NET MVC Ajax: How to update an Ajax.ActionLink itself on-click

I have a page that displays a list with a of elements with a large number of elements, each of which has a boolean property, representing an Enabled and a Disabled state.
I need to provide the user with a link for each list item, and the link text must show the opposite status (so if the item is enabled, the link text must display 'Disable').
When the user clicks the link for a Disabled, the corresponding link text for the item must change to 'Enable' (and vice versa).
I would like to NOT reload the entire list for each click, just the text of the ActionLink itself, so my question is:
Is it possible to update just an ActionLink itself when the user clicks the link, or do I have do handle this using custom javascript?
As far as I remember, you can add HTML attributes to the "a" tag by newing up an anonymous class as the last param on most overloads.
Off the top of my head this can be written like the following:
Html.ActionLink("Name", "Action", "Controller", new { #class = 'updateId' });
(You may be able to do this with an ID which would be preferable over a class - if not just use a unique class name to avoid updating multiple items.)
Then you can use javascript to access the class "updateId" and change the inner html.
In the case of jQuery:
$("a.updateId").html("NewName");
This can be done with a custom user control contained within the element to update. A writeup of the solution can be found here. No custom client-side scripting is necessary.

Resources