Improving performance:How to know selected rows in af:table through chk box
Hi,
I've a VO which has 3 transient variables. 2 of these transient variables getting the values from a view accessor. Using the other transient variable in the Ui to select the rows in the af:table.
In my UI, I've a table and a Check Box to select the rows. I want to get the selected rows through the check box, in the backing bean for my business requirements.
I've used below logic to get the selected rows. Here, I am iterating through the entire viewobject rows, so it is impacting the performance of the UI. How can I know the selected rows in the bean? or How can I improve the performance?
I also applied below view criteria, but still its not performant.
// ViewCriteria vc = vo.createViewCriteria();
// //.getViewCriteriaManager().getViewCriteria("SelectedMerchantCriteria");
// ViewCriteriaRow vcr = vc.createViewCriteriaRow();
// vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE | ViewCriteria.CRITERIA_MODE_QUERY);//MerchantName1
// //vcr.setAttribute("MerchantName1", "1017 CAFE");
// vcr.setAttribute("SelectToMap", "true");
// vc.addRow(vcr);
// vo.applyViewCriteria(vc);
// vo.executeQuery();
public void mapSupplierMerchant2(ActionEvent actionEvent) {
// Add event code here...
OperationBinding method = null;
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
Map pageFlowScope = adfFacesContext.getPageFlowScope();
ArrayList merchantMappingList = new ArrayList();
Long primaryVendorId = null, groupId = null;
CollectionModel tableModel = (CollectionModel) this.getMerchantTable().getValue();
JUCtrlHierBinding tableBinding = (JUCtrlHierBinding) tableModel.getWrappedData();
ViewObject vo = tableBinding.getViewObject();
// ViewCriteria vc = vo.createViewCriteria();
// //.getViewCriteriaManager().getViewCriteria("SelectedMerchantCriteria");
// ViewCriteriaRow vcr = vc.createViewCriteriaRow();
// vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE | ViewCriteria.CRITERIA_MODE_QUERY);//MerchantName1
// //vcr.setAttribute("MerchantName1", "1017 CAFE");
// vcr.setAttribute("SelectToMap", "true");
// vc.addRow(vcr);
// vo.applyViewCriteria(vc);
// vo.executeQuery();
List<JUCtrlHierNodeBinding> merchantList = (List<JUCtrlHierNodeBinding>)tableBinding.getChildren();
JUCtrlHierNodeBinding merchantNode = null;
List supToMap = new ArrayList();
boolean isMerchantSelected = false, isMasterSup = false;
Long merchantIdToMap = null, masterSupId = null;
Row r = vo.first();
while(r!=null) {
System.out.println("================================ " + r.getAttribute("MerchantName1") + " " + r.getAttribute("SelectToMap") );
if(r.getAttribute("SelectToMap")!=null) {
isMerchantSelected = (Boolean) r.getAttribute("SelectToMap");
if(isMerchantSelected) {
merchantIdToMap = (Long) r.getAttribute("MerchantMapId");
if(merchantIdToMap!=null) merchantMappingList.add(merchantIdToMap);
r = vo.next();
if(merchantMappingList.size()>0) {
primaryVendorId = (Long) pageFlowScope.get("primaryVendorId");
groupId = (Long) pageFlowScope.get("groupId");
method = (OperationBinding) ADFUtil.findOperation("mapSupplierMerchant");
if(method!=null) {
Map paramMap = method.getParamsMap();
paramMap.put("vendorId", primaryVendorId);
paramMap.put("groupId", groupId);
paramMap.put("merchantList", merchantMappingList);
Boolean result = (Boolean) method.execute();
List errors = method.getErrors();
if(result!=null && result) {
this.getMerchantMappedFlag().setValue(true);
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getMerchantMappedFlag());
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getMerchantTable());
tableBinding.getViewObject().setRangeSize(25);
FacesMessage message = new FacesMessage("The selected merchants have been mapped to the group. Please save the changes. " );//+ adfFacesContext.getPageFlowScope().get("merchantGroupName") );
message.setSeverity(FacesMessage.SEVERITY_INFO);
FacesContext.getCurrentInstance().addMessage(null, message);
} else {
FacesMessage message = new FacesMessage("No merchants have been selected for mapping. Please select atleast one merchant." );//+ adfFacesContext.getPageFlowScope().get("merchantGroupName") );
message.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(null, message);
}
Hi
Please check this post [http://adfwithejb.blogspot.in/2012/08/hi-i-came-across-one-common-use-case.html].
It has clear explanation of how to provide a checkbox for selection of rows. You can also go through my comments at the end of the post. That should solve your problem of iterating through the entire VO.
Thanks,
Rakesh
Similar Messages
-
How To Edit Selected Row In ALV Table
Hello Experts,
In My Webdynpro Application, I am displaying records from database table into an ALV Table.
I want to edit only selected record from ALV table.
Please Suggest How to achieve this.
Thanks,
PratibhaThe link given above is for the UI element 'Table' and does not pertain to ALV.
To Make an ALV Editable on lead selection for that particular lead selected row.
1. The ALV should be made lead selectable, when initializing
2. The ON_LEAD_SELECT function should be invoked.
3. Withing this function the index has to be retrieved to know which row was selected.
4. Based on the index retrived all the columns have to pass FALSE to read_only in the column properties.
Regards,
Pramod -
How To get selected row in a table
Hi experts
I have been using a table in which I am using a column Tree by nesting . I have written code for dynamically expanding table tree . But I want to know current selected element of the table, for this i have done following
steps
1) created an action on Action <b>lead select </b> of the table .
which has a parameter with type node element .
2) now i need to use parameter mapping in domodify view .
as
IWDTable tab = (IWDTable) view.getElement("CatalogTable");
tab.mappingOfOnLeadSelect().addSourceMapping<b>("XYZ",</b> "element");
But i dont know what is correct parameter <b>XYZ</b> to be passed.
also if i am wrong in approach please let me know .
Regards
AbhayHi
I have used following code also but its not working
IWDTable table = (IWDTable) view.getElement("CatalogTable");
table.mappingOfOnLeadSelect().addSourceMappin ("IWDNodeElement", "LeadSelect");
and I have created an action
public void onActionOnleadSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.sap.tut.wd.treetable.wdp.IPrivateTreeTableView.ICatalogElement LeadSelect )
//@@begin onActionOnleadSelect(ServerEvent)
wdContext.currentContextElement().setDebug4(LeadSelect.getID());
//@@end
but when i select one row its giving error
<b>com.sap.tc.webdynpro.services.exceptions.WDIllegalArgumentException: Parameter IWDNodeElement not found</b> -
How to control selected row in result table on a search page?
Using JDeveloper 10.1.3.2.0
I have attempted to create an ADF page that contains a search and result table in the same page.
I have questions related to the result table. Let's say the result table shows 10 rows per page.
If I page forward there is no default selected row "clicked" on the page. Only if you return to
the very first 10 rows do you see a default selection in row number one of the results.
How would I go about making the first row of each page the default selection?You'll need to code this into the RangeChangeEvent event of the table.
http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/apidocs/oracle/adf/view/faces/component/core/data/CoreTable.html
That said - I'm not sure this will be very helpful for the end user - after all in any case they'll need to first select a row before doing an operation on it. -
ALV - How to set selected rows into internal table
Hi all,
I am tying to set with an 'X' flag the selected rows in my ALV using an internal table that contains all rows showed.
More exactly I have tried to follow these steps.
1) I have added the filed SEL (type SEL) to my ALV structure zrt_bo_slabsend and I defined my internal table in this way
DATA: gt_report TYPE STANDARD TABLE OF zrt_bo_slabsend,
gw_report TYPE zrt_bo_slabsend.
2) I have set gw_layo-box_fname = 'SEL' to gw_layo (ALV layout)
Pressing the "delete button" that I have insert on the top of the ALV, I intercept correctly my user command and I call a form (named "delete_lines") where I have this abap code
FORM delete_lines.
DATA: l_subrc LIKE sy-subrc,
lw_grid_settings LIKE lvc_s_glay.
gw_layo-box_fname = 'SEL'.
"set field name to store row selection
gw_layo-edit = 'X'. "makes whole ALV table editable
gw_layo-zebra = 'X'.
gv_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_callback_program = gv_repid
i_callback_pf_status_set = gc_status
i_callback_user_command = gc_user_command
is_layout_lvc = gw_layo
it_fieldcat_lvc = gw_fkat
i_grid_settings = lw_grid_settings
i_save = 'X'
is_variant = variant
it_events = gt_events
TABLES
t_outtab = gt_report
EXCEPTIONS
program_error = 1
OTHERS = 2.
LOOP AT gt_report ASSIGNING <report> WHERE SEL = 'X'.
DELETE gt_report.
ENDLOOP.
ENDFORM.
I'd like to select many rows in my ALV report, than by pressing the delete button I'd like to see a refresh of my ALV, without the selected rows. I want to save it only at the end of my action, only by pressing the save button.
Any suggestion about the abap code will be well appreciated.
Thanks in advance for your kind help.
Regards.
GiovanniHi Giovanni,
I am using the method:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = gd_REPID
I_CALLBACK_PF_STATUS_SET = 'UDIT'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Mainatin cell entry'
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = GS_LAYOUT
IT_FIELDCAT_LVC = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
I_DEFAULT = 'X'
* I_SAVE = 'X'
* IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
I_SCREEN_START_COLUMN = 30
I_SCREEN_START_LINE = 14
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 25
* IT_EXCEPT_QINFO_LVC =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_ZCP_DEMAND_SYS1
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I have made five buttons on my toolbar (add, delete, save, back, exit).
Kindly tell me how can I catch the sy-ucomm of these buttons.
NOTE: this FM is written inside an user-exit, so I cannot make forms.
Thanks in advance. -
How to maintain selected row in adf table displayed after refresh
Hi,
I am using jdev 11g
I my jsf page I have a table with multiple rows.
When i scroll and click on one of the rows its selected but if the page is refreshed the row is always selected but not displayed.
I need to be able to maintain the selected row after the refresh of the page, so my table will look like its already scrolled to the selected row..
I tried to use the attribute displayRow="selected" but it won't do the trick.
Any hints
EmileHi Branislav,
Kindly answer the following if you may.
Is there a way to refresh the table after the selectListner is fired.
Automatically when i select the table i need to refresh it.
Why after refresh the selected row changes skin.
Regards -
How determine the selected rows in a table
Hi All,
I have a table with a multi selection enabled. Now if the 3 and 5 rows are selected how do I determine this using properties or methods/apis?
Thanks in advance.
Best regards,
DivyaLet <i>Rows </i>be the context node to which the property Table.<i>dataSource</i> is bound.
Then you get the selected context elements / table rows via the context API:
for (int j = 0, n = wdContext.nodeRows().size(); j < n; ++j)
if (wdContext.nodeRows().getLeadSelection() == j
|| wdContext.nodeRows().isMultiSelected(j)
/* row at index j is selected */
Armin -
How to get selected Row Index in a table based ona VO?
Hi All,
I'm writing an ADF form wherein I use a VO based on a SQL query. I'd like to know how to get the index of a selected row. I havea selection Listener in place where I can print the selected Row's data using getSelectedRowData().toString() on the table.
How can I get certain Attributes from this selected row.
One solution I thought of is to get the row index and then read attributes. But I cant seem to figure out how to get rowIndex for a selected row. Any sugestions?
Using JDeveloper 11g.
Thanks
P.If your selected row is marked as current row you can use
// Get a attribute value of the current row of iterator
DCIteratorBinding iterBind= (DCIteratorBinding)dcBindings.get("testIterator");
String attribute = (String)iterBind.getCurrentRow().getAttribute("field1");Where 'testIterator' is the name of the iterator you use for the table and 'field1' is the name of an attribute you want to get.
Or you can iterate over the selected row keys (even if it's only one):
// get selected Rows of a table 2
for (Object facesRowKey : table.getSelectedRowKeys()) {
table.setRowKey(facesRowKey);
Object o = table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o;
Row row = rowData.getRow();
TestRow testRow = (TestRow)((DCDataRow)row).getDataProvider() ;
}Where TestRow is the row type of the VO of your table.
Timo -
How to edit selected rows in a datagrid?
Hi all,
I am new to flex and I would like to know how to edit
selected rows( through check boxes) in a data grid. As of now the
whole data grid becomes editable.
Regards
Saran.This is not simple in Flex 2.0.
You will need to use a custom itemRenderer.
Search the net, perhaps someone has a component or sample
close to what you want.
Tracy -
How to know the the list of tables with no rows inside a schema?
with reference to
http://www.ss64.com/orad/USER_TABLES.html
How to know the the list of tables with no rows inside a schema?
I try this select table_name from user_tables where num_rows=0;
I can found one table that is empty.
So what's the query to return list of tables in a schema which has no rows?
thanksYou can do that only if your have collected the stats properly. Otherwise its going to show you wrong information.
Check this out...
SQL> drop table t
2 /
Table dropped.
SQL> create table t
2 as
3 select level no from dual connect by level <=100
4 /
Table created.
SQL> select table_name,num_rows from user_tables where table_name = 'T'
2 /
TABLE_NAME NUM_ROWS
T
SQL> begin
2 dbms_stats.gather_table_stats(user,'T');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> select table_name,num_rows from user_tables where table_name = 'T'
2 /
TABLE_NAME NUM_ROWS
T 100
SQL>Thanks,
Karthick. -
How can i update rows in a table based on a match from a select query
Hello
How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
Thanks Glenn
table1
attribute1 varchar2 (10)
attribute2 varchar2 (10)
processed varchar2 (10)
table2
attribute1 varchar2 (10)
table3
attribute2 varchar2 (10)
An example:
set table1.processed = "Y"
where (table1.attribute1 = table2.attribute1)
and (table1.attribute2 = table3.attribute2)Hi,
Etbin wrote:
Hi, Frank
taking nulls into account, what if some attributes are null ;) then the query should look like
NOT TESTED !
update table1 t1
set processed = 'Y'
where exists(select null
from table2
where lnnvl(attribute1 != t1.attribute1)
and exists(select null
from table3
where lnnvl(attribute2 != t1.attribute2)
and processed != 'Y'Regards
EtbinYes, you could do that. OP specifically requested something else:
wgdoig wrote:
set table1.processed = "Y"
where (table1.attribute1 = table2.attribute1)
and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
But there is no argument about what needs to be done when processed is NULL.
OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary. -
How to get selected row index of a Table ?
hi gurus,I'm new to Webdynpro for abap
I'm displaying just Flight details in a Table so
how to get selected row index of a Table and need to be display in Message manager.Hi,
For getting the row index use the following code.
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA index TYPE i.
* navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
lo_el_node = lo_nd_node->get_lead_selection( ).
index = lo_el_node->get_index( ).
node is the name of the node which is binded to the table.
For printing the message u can use code wizard.
Press ctrl-F7. Now Select generate message.
IN this select the method REPORT_SUCCESS
In the code now u can give index to Message text Exporting parameter. Comment receiving parameter.
Write the whole code in onLeadSelect of the table.
Regards,
Pankaj Aggarwal -
How to get selected row keys from RichSelectManyCheckbox
Adf Table has getSelectedRowKeys but SelectManyChekcbox does not has anything similar. Can you tell me how to get selected row keys programmatically for RichSelectManyCheckbox?
Hi User,
selectManyCheckbox component's value property holds the selected items values. Bind this property to some bean variable(of type list) so that you can get the selected values by accessing the bean property.
Sireesha -
How to set focus on a input field in a selected row of a table?
In a previous discussion (http://scn.sap.com/thread/3564789) I asked how to access an input (sap.m.Input) field of a selected row in a table. In the answer that was supplied I was shown how to get the items of the table. Then using the selected index to get the selected item get the cells. Then I could set editable on the proper cell(s). This worked fine.
Now I need to set the focus on one of the fields. I tried something like this:
var oNewLink = table.getSelectedItem();
var oNewLinkName = oNewLink.getCells()[1];
oNewLinkName.focus();
But this doesn't seem to work.
I have searched through other discussions and have seen this technique for putting focus on a field if you have its ID:
sap.ui.getCore().byId(id_of_the_input_field).$().focus();
In my case though I do not have an ID since the row and its cells are generated. How can I set focus on the cell of a certain row in a table?Hello Venkatesh. Yes that code does work. First I tried it on a table cell that was already rendered and it did work. The next time I tried it on a table row that was being added and it did not work there. So I added an on after rendering function for the table and added that code there. That did not work until I added a delay (timeout) to do a context switch before calling the focus and that worked.
Once last thing though sometimes when I call focus on an input field (actually in a table row cell) if the field has text in it already the flashing cursor is at the beginning of the text and other times it is at the end of the text (which is the desired way). It depends on where I click in the row. Is there anyway to make sure the flashing cursor is at the end of the text when the focus is applied to a field that contains text? -
How to get selected row from table(FacesCtrlHierBinding ).
I'am trying to get selected row data from table:
FacesCtrlHierBinding rowBinding = (FacesCtrlHierBinding) tab.getSelectedRow();
Row rw = rowBinding.getRow();
But import for oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding cannot be found from my JDev 11.
What is correct package for FacesCtrlHierBinding?Hi, another problem.
I fill table with data manualy from source:
<af:table var="row" value="#{getCompanyData.com}"
rowSelection="single" columnSelection="single"
editingMode="clickToEdit"
binding="#{getCompanyData.tab}"
selectionListener="#{getCompanyData.GetSelectedCompany}">
<af:column sortable="false" headerText="col1">
<af:outputText value="#{row.id}"/>
</af:column>
<af:column sortable="false" headerText="col2">
<af:outputText value="#{row.name}"/>
</af:column>
<af:column sortable="false" headerText="col3">
<af:outputText value="#{row.phone}"/>
</af:column>
</af:table>
and when I'am trying to use method to get selected row:
RichTable table = this.getTab(); //get table bound to UI Table
RowKeySet rowKeys = table.getSelectedRowKeys();
Iterator selection = table.getSelectedRowKeys().iterator();
while (selection.hasNext())
Object key = selection.next();
table.setRowKey(key);
Object selCompany = table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding) selCompany;
row = rowData.getRow();
I got an error:
SEVERE: Server Exception during PPR, #1
javax.el.ELException: java.lang.ClassCastException: data.COMPANY cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding
When I created tables by dragging data from date control, all worked fine.
What could be a problem?
Maybe you are looking for
-
Tips and tricks on how to start using iCloud
I'm currently using plain iTunes sync to sync my calendars between my iMAC and various iPods and iPads. It's a bit labour intensive to keep all devices in sync, so I've decided to use iClouds for that purpose. But before I start I would like some adv
-
Image gets stretched when menu slides out on the iPad
I'm using this docking menu (http://www.jankoatwarpspeed.com/examples/AdvancedDocking/) with some small changes and running into an issue with the left menu stretching to the size of the 'dock' menu. I can only recreated it on the iPad and not with a
-
Intel Mini - HDTV with DVI or HDMI Problems
Hello With my Samsung LE32 and the Intel Mini I get overscan in HDTV resolutions like 1280x720, so I used DisplayConfigX to go from 1280x720 (overscan) to 1240x680 128 Front Porch 19 80 Sync 5 240 Back Porch 38 1688 Total 750 As you can see in the fo
-
Hi All, We are currently trying to integrate an Xcesius dashboard within a BPC 10 workspace however the documentation is rather 'thin' in this area. While trying to follow the BPC 7.5 documentation there are some clear differences in the steps you ne
-
Is there any way to export a FR report to a HTML file? In workspace you can see FR reports as HTML, but I can't see a way to export it. We would like to export the FR report and publish it on a server that don't have workspace. I know that one way co