How to Refresh adf table after insert a new row - jpa

Hello I have two pages: the first is "creer dossier.jsf" where I can add a new row and the seconde page is "listdossier.jsf" inside it i have a read only table that contains the records of the first page.
when I create a record in the first page it persist in the database but can't appears in the table only when i redploy the application .
I want to get the newest records without redeploying the application..can someone help me please??
to create the table i just drag it from the data control.
I am using EclipseLink JPA as ORM and web logic
I tried to delete the cache using from the persistanc.xml and em.refresh() and always the same problem
here's my table:
<af:table value="#{bindings.dossierFindAllParDepartementDBTE.collectionModel}"
var="row" rows="#{bindings.dossierFindAllParDepartementDBTE.rangeSize}"
emptyText="#{bindings.dossierFindAllParDepartementDBTE.viewable ? 'No data to display.' : 'Access Denied.'}"rowBandingInterval="0"
fetchSize="#{bindings.dossierFindAllParDepartementDBTE.rangeSize}" id="t2"
partialTriggers="l1" width="796px"
immediate="false" binding="#{backingBeanScope.BeanDatabase.t2}">
<af:column headerText="ID_Dossier" id="c5" width="150"
inlineStyle="background-color:#b5ffde">
<af:link actionListener="#{bindings.setCurrentRowWithKeyValue.execute}"
text="#{row.idDossier}"
disabled="#{!bindings.setCurrentRowWithKeyValue.enabled}" id="l1"action="GoEditDossierBTEDEP1" inlineStyle="background-color:#b5ffde"/>
</af:column>
<af:column headerText="Client" id="c6" width="150"
inlineStyle="background-color:#b5ffde">
<af:outputText value="#{row.client}"
shortDesc="#{bindings.dossierFindAllParDepartementDBTE.hints.client.tooltip}"
id="ot6"/>
</af:column>
<af:column headerText="Ingénieur" id="c7" width="150"
inlineStyle="background-color:#b5ffde" headerClass="skin1.css">
<af:outputText value="#{row.ingAff}"shortDesc="#{bindings.dossierFindAllParDepartementDBTE.hints.ingAff.tooltip}"id="ot7"/>
</af:column>
<af:column headerText="Probléme" id="c8" width="300" inlineStyle="background-color:#b5ffde">
<af:outputText value="#{row.descriProb}"
shortDesc={bindings.dossierFindAllParDepartementDBTE.hints.descriProb.tooltip}"
id="ot8"/>
</af:column>
</af:table>

In the task flow that navigates between the two pages, stick a method activity that does a call to the query and re-execute it before you go back to the first page.

You can do that in 2 ways:
Refresh the Page or the Particular component of second page on Submit of the first page.
Refresh the Iterator and VO after submitting the values in the first page

Related

SAPUI5 - How to change the table in the same View?

situation:
2 diferent tables, 1 view;
want to achieve:
I've got to change the table when I change the selectedKey in a select.
I already tried to create fragments with each table and call the one I want when I change the select.
fragment1 - table 1
fragment2 - table 2
select - oEvent (onChangeSelect) - getSelectedKey - if(key === 1) - call fragment1, if(key === 2) - call fragment2, but it gives me an error.
I don't know if this is correct and I'm not finding any infos related online.
If someone can show some links or give me just an idea on how can I do this, it would be perfect.
You could use the concept of binding to achieve this without coding. assume you have something like that in your view:
<Select><!-- ... --></Select>
<core:Fragment ... /><!-- table 1 -->
<core:Fragment ... /><!-- table 2 -->
First, add a model to your app, which will contain the information about the status of the app (which of the fragments is visible currently). Easiest way is to start with an empty JSON model. If you are familiar with manifest.json config, add it there. if not, you could add this in your Components init method:
this.setModel(new JSONModel(), "config");
This way, the new empty model is available under the name "config" in all the views of the app.
Now, we will add a visibility flag, which will control the visibility of your fragments (tables), and can be changed by the select:
<Select selectedKey="{config>/selectedFragmentKey}">
<core:Item key="" text="Please choose one" />
<core:Item key="showFragment1" text="Show Fragment 1" />
<core:Item key="showFragment2" text="Show Fragment 2" />
</Select>
This new version will store the key of the selected item in the config model in the path /selectedFragment. Add visibility flag to fragments (tables):
<!-- table 1 is only visible if "Show Fragment 1" was selected -->
<Table visible="{= ${config>/selectedFragmentKey} === 'showFragment1'}" .../>
<!-- table 2 is only visible if "Show Fragment 2" was selected -->
<Table visible="{= ${config>/selectedFragmentKey} === 'showFragment2'}" .../>
and you're done.
Main lesson here: learn to use bindings.
If I understood the question correctly, you have a selection control (which has 2 entries), and a table in the view. Based on the selection item, you want to display ONE of the tables at any given point of time. I am also assuming here, that the tables are purely used in the current view only & not really a "re-useable" thing - which gets used in different places of the app (which then renders the use of fragments an overkill).
I am assuming, both tables are bound (although to different data sets).
In that case, consider using the "visible" property of the appropriate table to "false".
Remember - all UI components, including tables inherit from sap.ui.core.Control - which has the "visible" property.
In API reference for table : https://sapui5.hana.ondemand.com/#/api/sap.ui.table.Table%23methods/Summary
If you scroll down to "Borrowed from:" section, you will see the "setVisible" and "getVisibe" methods.
So, in the event fired during selection change, you can grab the table control & set the visibility using the aforementioned methods.
Alternatively, you can also set an expression binding directly on the table control in XML, which evaluates to "true" or "false" (perhaps using a formatter).
Let me know if you need further info on this.
Best Regards,
Gopal Nair.

sap.m.table pagination issue

table defined as follows
<Table id="idSC_HdrList" mode="MultiSelect" editable="false"
growing="true" growingThreshold="10"
A search function populates the table from an Odata call, the first result works fine.
However when I click on the More button, the number of records correctly show 20 rows ( 10 + 10 ), but the more button overall count has jumped from 39 to 49.
This continues on each subsequence more button
Anyone come across this before and why this is happening? I have set the binding to one way on the odata model (not sure if it has anything to do with it, but it was mentioned in the growing property)
OK, thanks for the comments on this question, when I was copying out the code to give more details for the Odata service in Component.js, I noticed I had disabled the setCountSupported on the service.
Once I commented this out and re-tested, the pagination function works correctly now.
//oModel.setCountSupported(false);

Meteor: record in db updating, but data not changing on screen

Here's a simplified version of what I have in one of my templates:
{{#each dataRecord}}
{{#if editingNow}}
<tr class="dataRow">
<td><button class="updateRecord" id="{{this._id}}">SAV</button></td>
<td><input type="text" id="{{this._id}}" value="{{this.f}}"></td></td>
</tr>
{{else}}
<tr class="dataRow">
<td><button class="edit" id="{{this._id}}">EDIT</button></td>
<td>{{this.f}}</td>
<td><button class="deleteRecord" id="{{this._id}}">DEL</button> </td>
</tr>
{{/if}}
{{/each}}
editingNow returns the value of boolean session variable which starts out as false. So when the page loads, the user sees the value of the 'f' field for each record and the EDIT button. The EDIT button flips the session variable to true and then the data is shown using an input element. The user can edit the data and click the button, which is now a SAVE button. That button updates the record using the _id and flips the session variable back to false.
The works as far as editing the data goes -- the record is definitely getting updated. I can check the value in the console and see that it has been changed. But the data that gets displayed in the table reverts back to the original value. I can see the change displayed in that field very briefly and then it flips back. Even weirder, if I click the EDIT button again, the table still displays the old value. The only way to see the updated data in that field is to restart the app.
This problem never occurred when I was using my local mongo db or when I was linking to my database on meteor.com. This has only started happening since I moved my app to modulus.io. Any ideas?
UPDATE
Although I could not figure out what was causing the reactive update problem in the template, with Ethaan's help, I was able to get a better understanding of the issue and find a work-around, so I've accepted the answer and hopefully we will get to the bottom of this eventually.
Seems like you have some allow/deny problems maybe?
Try with
Collection.allow({
insert:function(){return true;},
remove:function(){return true;},
update:function(){return true;},
})
Or check the connection with the database is succefull, go to the admin panel on modulus
Option 2
Clean the database and make a dummy insert on the server side.
First on the meteor shell run meteor reset.
OR If you have the application is on modulus.io use the mongo shell, and use this piece of code.
db.getCollectionNames().forEach(function(name) {
if (name.indexOf('system.') === -1) {
db.getCollection(name).drop();
}
})
Now when you are sure the database is empty, put this on the server side.
//Server Code.
Meteor.startup(function(){
if(Collection.find().count() == 0){
Collection.insert({serverInsert:"test from server"},function(err,result){
if(!err){
console.log("insert succefull")
}
})
}
})

Ace Datatable row selector with paginator

I am using ace datatable with pagination. Now, in a page after selecting some rows, when I go to another page and come back, the selection disappears. Rows are not selected anymore.
Here is the code:
<ace:dataTable var="device" value="#{reportBean.searchTableList}"
id="MeterTable" rows="10" paginator="true"
paginatorPosition="bottom" page="1" selectionMode="multiple"
stateMap="#{reportBean.rowStateMap}" pageCount="4"
rowStyleClass="oddRow1,evenRow1">
<ace:column id="column3" headerText="Meter Name"
sortBy="#{device.device_name}" filterBy="#{device.device_name}"
selected="true"
filterMatchMode="contains" styleClass="dataTableHeader">
<ice:outputText value=" #{device.device_name}" />
</ace:column>
</ace:dataTable>
Seems like your reportBean is RequestScoped.
this means when you browse to the page with the table the reportBean is loaded and when you do a selection the selection values are stored in reportBean.rowStateMap. when browsing to another page the reportBean and the selection information get deleted because it is not the same request (Request Scoped!). when you browse to the table page again, a new reportBean is created which doesn't has any information about the selection
You can try changing your reportBean to SessionScoped but that has other impacts which you should consider.

ObjectDataSource.Select with Parameters Time Out

I'm using an ObjectDataSource with a 2008 ReportViewer control and Linq to CSV. The ODS has two parameters (the SQL is spelled out in an XSD file with a table adapter). The Reportviewer takes a very long time to render the output after a button is clicked to generate the report. That's my first problem. Even though it works (most of the time), the processing time worries me, and subsequent requests don't seem to be changing the results shown on the screen. The next issue is that when I go to export the ODS to CSV I'm getting a time out exception on the select method of the ODS (shown below). This works for ODS without parameters, but it seems like now that I've added parameters that it doesn't want to cooperate. I'm fresh out of ideas, any thoughts?
<asp:ObjectDataSource ID="obsGetDataAllCustomers" runat="server"
SelectMethod="GetDataAllCustomers"
TypeName="my.myAdapter.AllCustomers"
OldValuesParameterFormatString="original_{0}" >
<SelectParameters>
<asp:ControlParameter ControlID="StartDate" Name="Start" PropertyName="Text"
Type="DateTime" />
<asp:ControlParameter ControlID="EndDate" Name="_End" PropertyName="Text"
Type="DateTime" />
</SelectParameters>
</asp:ObjectDataSource>
After button click to view report -
rvAllCustomers.LocalReport.Refresh()
Export to CSV (adding the items returned to a list which is then processed by working code) -
For Each dr As DataRow In CType(obs.Select(), DataView).Table.Rows
l.Add(New FullOrderOutput(dr))
Next
Unfortunately (or fortunately I suppose in this case - loads of data here) I didn't find a direct solution to this problem. Instead, I used a query (probably using a SQLAdapter or something like that - it's been a while) and specified the parameters manually within that bit of code, then if I recall, supplied the report's datasource the adapter.