on 04-27-2006 10:15 PM
I see most of the solutions in SDN is for Classical BSP page programming model and very few for MVC design pattern. Could someone please help me understand how to use iterator using MVC? This is what I did and it is giving me error - "A dynamic type conflict occurred during reference assignment."
=========================================
Code
=========================================
Implemented the interface IF_HTMLB_TABLEVIEW_ITERATOR in a class - ZPESTVI_REVWTYPE
Defined class attribute M_ROW_REF instance public type ref to zt_revw_type (table type)
Implemented the methods:
IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS.
FIELD-SYMBOLS: <def> LIKE LINE OF p_column_definitions.
APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.
<def>-COLUMNNAME = 'REVW_CODE'.
<def>-SORT = 'X'.
APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.
<def>-COLUMNNAME = 'REVW_DESC'.
<def>-EDIT = 'X'.
<def>-SORT = 'X'.
APPEND INITIAL LINE TO p_column_definitions ASSIGNING <def>.
<def>-COLUMNNAME = 'ACTV_FLAG'.
<def>-EDIT = 'X'.
<def>-SORT = 'X'.
method: IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START.
m_row_ref ?= p_row_data_ref.
method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.
CASE p_column_key.
WHEN 'ACTV_FLAG'.
p_replacement_bee = CL_HTMLB_CHECKBOX=>FACTORY
( id = p_cell_id
checked = 'm_row_ref->ACTV_FLAG' ).
ENDCASE.
====================================================
In my controller:
DO_REQUEST
create the iterator
create object c_iterator type ZPESTVI_REVWTYPE.
create view instance
v_revwtype = create_view( view_name = 'zrevwtype.htm').
v_revwtype->set_attribute( name = 'v_tviterator' value = c_iterator ).
where c_iterator is defined as controller attribute instance public type ref to IF_HTMLB_TABLEVIEW_ITERATOR.
===================================================
In my view:
<htmlb:form id="MyForm">
<htmlb:tableView id = "tv1"
visibleRowCount = "15"
selectionMode = "LINEEDIT"
table = "//vmodelsetup/m_revwtype"
iterator = "<%= v_tviterator %>" />
</htmlb:form>
where v_tviterator is defined as page attribute type ref to IF_HTMLB_TABLEVIEW_ITERATOR.
========================================================
First of all it doesn't work. Secondly, how do I display the checkbox with data binding?
Please help.
Thanks,
Partho
OK, Finally I got it somewhat working.
I have taken out the code from method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START.
m_row_ref ?= p_row_data_ref.
Although m_row_ref and my table in iterator was the same table type.
Now, the output displays checkbox with label "Flag" next to it. How do I get rid of the lable "Flag"? I tried using text=' ' but that didn't work.
Also, I could check/uncheck any checkboxes irrespective of record selection (lineedit). Other fields are available for edit only when I select the record but all checkboxes are available for input. How do I control this?
Finally, how can I enhance this screen to support select/insert/update/delete operation?
Thanks a bunch.
Partho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Now, the output displays checkbox with label "Flag" next to it. How do I get rid of the lable "Flag"? I tried using text=' ' but that didn't work.
Because you are data binding it is pulling the field description automatically from the reference field. In ABAP there is an important difference between ' ' and ` `. With ' ' any trailing spaces are elimitated. Therefore nothing is passed to the text attribute and the binding value is used. However try ` ` instead. This usage preserves trailing spaces.
>Other fields are available for edit only when I select the record but all checkboxes are available for input. How do I control this?
You are creating the inner control so it is your responsibility to set if the control is ready for input or not. RENDER_CELL_START has an import parameter (P_EDIT_MODE) to tell you if the cell is in edit mode or not. If the entire table is in edit mode then you might have to read the line selection of your table. Either way you would control this by simply setting the disabled attribute of the factory method for the checkbox element.
>Finally, how can I enhance this screen to support select/insert/update/delete operation?
You will have to add your own buttons or menu options that trigger server side events. From there you can manipulate the internal table (deleting/adding rows) and edit mode/line selection index.
Hi Partho Ghatak,
I am very fresher to CRM and BSPs with MVC approach. In my company i have a requirement to make lead result view as editable so that user can change status and qualification of lead. I think you have done some what same. If you can send me coding/document, then it will be very helpful for me. Please help me.
Thanks in Advance.
Regards,
Nizamuddin,
+91-9989052354
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thomas,
Thanks.
Very helpful answers. I have marked the topic as answered. Using p_edit_mode and disabled property I was able to achieve the desired result. Also, I used text = ' ' which removed the 'Flag' text from the check box.
I see your logic to implement select/insert/delete/update scenario. Will it be possible to direct me towards some code examples which will actually show how to track these events and update internal/db tables using MVC?
Partho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Will it be possible to direct me towards some code examples which will actually show how to track these events and update internal/db tables using MVC?
There is really nothing MVC specific about what you want to do. Any example that works with insert/delete/update on a tableView table should work. I don't have a specific example off hand, but I'm sure if you search through the BSP weblogs you will find some examples that do that. You might also have a look at the sample application SBSEXT_TABLE. Although it may not have the exact example you are looking for, it has some very good examples for working with tables in general.
Thomas,
Thanks once again for your quick reply. However I am still stuck - it doesn't work. All I am trying to do is maintain (select, insert, update, delete) a table using iterator/tableview using MVC:
Table Name: zrevw_type
Tab Cols: revw_code, short_desc, long_desc, actv_flag.
Data:
revw_code short_desc long_desc actv_flag
A Short A Long A X
B Short B Long B X
C Short C Long C
D Short D Long D X
I have defined a structure:
Structure: zsrevw_type
Col: revw_code, revw_desc, actv_flag
TableType: zt_revw_type based on structure zsrevw_type
Using this scenario could you please guide me with sample code how to achieve the result?
Partho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mr Jung,
Thanks for reponding so quickly. I do need some more guidance. Some code example would really help (MVC pattern please).
It appears the problem is somewhere else.
I commented everything in render_cell_start method: Right now it reads as followS:
WHEN 'REVW_CODE'.
IF p_edit_mode IS NOT INITIAL.
ENDIF.
WHEN 'REVW_DESC'.
IF p_edit_mode IS NOT INITIAL.
ENDIF.
WHEN 'ACTV_FLAG'.
IF p_edit_mode IS NOT INITIAL.
ENDIF.
and still getting the error.
Problem seems to be in RENDER_ROW_START code:
m_row_ref ?= p_row_data_ref.
my m_row_ref has been defined as clas attribute (instance/public/type ref to - ZT_REVW_TYPE) which is a table type of structure having columns revw_code, revw_desc, actv_flag.
In my tableview, table is bound:
table = "//vmodelsetup/m_revwtype"
where m_revwtype is also of type ZT_REVW_TYPE.
Is this ok?
If I comment the line in the method RENDER_ROW_START it works - with basic tableview display. The moment I remove the comment from RENDER_ROW_START method it fails.
What am I doing wrong here?
If you can give me some sample code for generating tableview with check box column it would really help. I bought the book :Advanced BSP..." but unable to find any MVC code there.
Thanks,
Partho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you sure that you have used the same type for your m_row_ref as the original table. Make sure one doesn't use a structure while the other has a table type.
However if you are using data binding you might not need to cast the data reference. You can use the following code to create the checkbox with the binding string:
WHEN 'ACTV_FLAG'.
p_replacement_bee = CL_HTMLB_CHECKBOX=>FACTORY
( id = p_cell_id
_checked = p_cell_binding ).
Well you can't pass 'm_row_ref->ACTV_FLAG'. The quote marks would cause you pass the text literal m_row_ref->ACTV_FLAG as the value.
Instead to use the bind, use the attribute _checked of the factory method. the _ attributes are the ones that accept binding strings. The the method of the interator already has input parameter that will contain the binding string for the current cell value. The name of the input parameter is p_cell_binding.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.