Dynamically create component
Same project as my last post but figured the context is different enough to merit a new thread.
I have a flex application called app.mxml and a component called dummy.mxml, the component consists of a text area and a button.
The application consists of 5 textInputs and a Canvas.
Is it possible that when the user types something into one of these text fields that there is an instance of dummy created within the canvas and the text area within dummy contains the text within the input field?
I'll try and explain it a little better,
in my main application I have a panel that contains 5 empty textInput boxes, these are all blank, next to the panel I have a canvas, this has nothing in it at all at this point.
there is also a component (dummyComponent.mxml) in the application that consits of a textArea and a radio button.
this component is not used within the application prior to runtime.
Runtime -->
user enters the text "testing 123" into the first textInput box. ad this point an instance of dummyComponent is created within the canvas and the contents of its text area mimic that of the input box.
The same effect could be achieved by having 5 textAreas within the canvs that each bind to the 5 textInputs, but i don't want these textAreas to exist unless they are needed.
Cheers
Tim
Similar Messages
-
Dynamic created component, problem to set position
hello,
I want to create in dynamic way label component and put it on GridPanel in given position. How can I set this position(x,y) to created component?
thanks in advanceHi, Jeff.
Just don't want to cross post the same answer all over the forum. So I gave some inputs on the topic in this message: http://forums.sdn.sap.com/thread.jspa?messageID=11127647�
Hope this will help you. -
Dynamic create Component usage and embed it in view container
There is a view_container_uielement VC_TEST in view V_MAIN, in wd component ZTEST.
I created a web dynpro component named ZWDR_TEST and add it into the wd component ZTEST.
gr_comp_test = component->create_cmp_usage_group(
name = 'TEST_GROUP'
used_component = 'ZWDR_TEST' ).
lr_comp_usage = me->gr_comp_test->add_component_usage(
embedding_position = 'V_MAIN/VC_TEST'
name = 'TEST'
used_component = 'ZWDR_TEST' ).
if lr_comp_usage->has_active_component( ) is initial.
lr_comp_usage->create_component( component_name = 'ZWDR_TEST' ).
endif.
ifc_test ?= lr_comp_usage->get_interface_controller( ).
I thought the wdr ZWDR_TEST was embeded in the view V_MAIN in the position VC_TEST by the embedding_position parameter.
But in the result web page, there is no ZWDR_TEST in the position of VC_TEST.
Could any one explain why?
ThanksHi,
for dynamic comp usage.. check this..
http://help.sap.com/saphelp_nw70/helpdata/en/bc/191a427ff6db2ce10000000a1550b0/frameset.htm
Dynamic Component Usage
embed view
Dynamic View embed
How to create a webdynpro view dynamically and embed into view container?
Cheers,
Kris. -
MethodnotFound Exception for dynamically created component(menuItem)
Hi
I have created menuItem component and tried to create Action Listener object and setting it to the component in the backing bean.
but it is throwing methodnot found exception.
javax.el.MethodNotFoundException: Method not found: [email protected]()
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Method not found: [email protected]()
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92)
Below is my code..
MenuItem item1 = new MenuItem();
item1.setValue(key);
Application app = FacesContext.getCurrentInstance().getApplication();
javax.faces.el.MethodBinding actionListener = app.createMethodBinding("#{breadCrumbBean.test}", null);
item1.setActionListener(actionListener);
Let me know whether i created actionListener object or not.
Any suggestions...
Thanks
Edited by: _user on Jan 20, 2011 9:27 PMHi,
I tried this it works for me...
Try to set as below...
MethodExpression ee = context.getApplication().getExpressionFactory().createMethodExpression(context.getELContext(), "#{breadCrumbBean.test}", String.class, new Class[] { });
item1.setActionExpression(ee);
Regards,
Suganth.G -
About dynamic creating component instance
my project is a lib project , and I can not create a mxml
component using getdedinitionbyname then new the class .
because the class reference I can not received using
getdedinitionbyname! Has any body know something about it?Why,there is so little developpers!But luckily I find the
answer,Just add a compiler parameter -include-librarirs to resoleve
it!! -
Finding Component on Dynamically Created UI
I am having a hard time regarding finding a particular component in my managed bean if your UI is dynamically created (say using an iterator..) especially
if you need that component during PPR.
As of the moment, I am doing this but its really ugly and is bound to be broken if I add another layout.
public void handleChange(ValueChangeEvent valueChangeEvent) {
UIComponent component = valueChangeEvent.getSource().getParent().getChildren().get(0).getChildren().getFacet("end").get(0).getChildren().get(1);
AdfFacesContext context = AdfFacesContext.getCurrentInstance();
context.addPartialTarget(component);
}This code wont work also, since at runtime, I wouldnt know the id of the component.
FacesContext facesCtx = FacesContext.getCurrentInstance();
facesCtx.getViewRoot().findComponent(name) ; Been thinking about this for sometime now. Help needed.you can use this instead
FacesContext.getCurrentInstance().getViewRoot().findComponent("<id>);
or
// used to locate region. Could also find any component
// located in the base ViewRoot()
public static UIComponent findComponentInRoot(String id) {
UIComponent component = null;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
UIComponent root = facesContext.getViewRoot();
component = findComponent(root, id);
return component;
// Recursive method which finds your component within JSFF
// regardless of facet or other UIComponents which may have children
public static UIComponent findComponent(UIComponent base, String id) {
if (id.equals(base.getId()))
return base;
UIComponent kid = null;
UIComponent result = null;
Iterator kids = base.getFacetsAndChildren();
while (kids.hasNext() && (result == null)) {
kid = (UIComponent) kids.next();
if (id.equals(kid.getId())) {
result = kid;
break;
result = findComponent(kid, id);
if (result != null) {
break;
return result;
} -
Problem with embeding the same view in dynamically created view container
Hello Experts,
I am getiing a dump when i try to embed the same view inside the dynamically created view container of
dynamically created tabs of a tabstrip
The requirement go like this, i have 2 views in which i have have to embed the 2nd view to view1 where i have an empty
tabstrip without tabs. During runtime i create tabs as well as view containers accordingly and then try to embed view2 in tabs.
I have put the below mentioned code in HANDLEIN,
DATA: lref_vcntlr TYPE REF TO if_wd_view_controller,
lref_comp TYPE REF TO if_wd_component_usage,
lv_embed_pos TYPE string.
lref_vcntlr = wd_this->wd_get_api( ).
lv_embed_pos = 'FILE_PERS_EDIT/VC_GENERAL'.
TRY.
CALL METHOD lref_vcntlr->do_dynamic_navigation
EXPORTING
source_window_name = 'FILE_PERSISTENCE_WND' " Window
source_vusage_name = 'FILE_PERS_EDIT_USAGE_1' " Source View usage
source_plug_name = 'TO_EDIT_LAYOUT' " Outbound plug
target_view_name = 'PERS_EDIT_LAYOUT' " Second view to be embedded
target_plug_name = 'IN' " Second view inboun plug
target_embedding_position = lv_embed_pos
RECEIVING
component_usage = lref_comp.
CATCH cx_wd_runtime_repository .
ENDTRY.
wd_this->fire_to_edit_layout_plg( ).
This works fine for the first time.
However onaction tab select i change the embeding position( 'FILE_PERS_EDIT/view container name of different tab') of the view2 an try to embed view2 in a different tab.
At this point i get a dump stating View2 already present in the window 'FILE_PERSISTENCE_WND' of component.
I think, the view2 embediing has to be removed before i add the view2 in a different tab
Kindly let me know how to remove view2 embedding from tab1 before i add a view2 to a different tab or is there any other
means to handle this problem?
Thanks & Best Regards,
Srini.Hello Srini,
I found a solution to your problem, because I had a similar task.
In WDDOINIT I changed the method do_dynamic_navigation to if_wd_navigation_services_new~prepare_dynamic_navigation:
DATA:
l_view_controller_api TYPE REF TO if_wd_view_controller.
l_view_controller_api = wd_this->wd_get_api( ).
TRY.
CALL METHOD l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation
EXPORTING
source_window_name = 'WDW_MAIN'
source_vusage_name = 'VW_SUB_USAGE_1'
source_plug_name = 'TO_VW_CONTENT'
target_component_name = 'ZTEST_DYNAMIC'
target_view_name = 'VW_CONTENT'
target_plug_name = 'DEFAULT'
target_embedding_position = 'VW_MAIN/VC_TAB.VW_SUB/TAB1_VC'
RECEIVING
repository_handle = wd_this->g_rep_handle.
CATCH cx_wd_runtime_repository .
ENDTRY.
wd_this->fire_to_vw_content_plg( param1 = 'TAB1' ).
In the action I first deleted the navigation targets, then navigated to the empty-view and last I called my target view:
DATA:
lv_position TYPE string,
l_view_controller_api TYPE REF TO if_wd_view_controller,
lr_view_usage TYPE REF TO if_wd_rr_view_usage,
lr_view_***_t TYPE wdrr_vca_objects,
lr_view_*** LIKE LINE OF lr_view_***_t.
l_view_controller_api = wd_this->wd_get_api( ).
lr_view_usage = wd_this->g_view->get_view_usage( ).
lr_view_usage->delete_all_navigation_targets( plug_name = 'TO_VW_CONTENT' ).
CLEAR lv_position.
CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' old_tab '_VC' INTO lv_position.
TRY.
l_view_controller_api->if_wd_navigation_services_new~do_dynamic_navigation(
source_window_name = 'WDW_MAIN'
source_vusage_name = 'VW_SUB_USAGE_1'
source_plug_name = 'TO_EMPTYVIEW'
target_component_name = 'ZTEST_DYNAMIC'
target_view_name = 'EMPTYVIEW'
target_plug_name = 'DEFAULT'
target_embedding_position = lv_position ).
CATCH cx_wd_runtime_repository.
ENDTRY.
CLEAR lv_position.
CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' tab '_VC' INTO lv_position.
TRY.
wd_this->g_rep_handle = l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation(
source_window_name = 'WDW_MAIN'
source_vusage_name = 'VW_SUB_USAGE_1'
source_plug_name = 'TO_VW_CONTENT'
target_component_name = 'ZTEST_DYNAMIC'
target_view_name = 'VW_CONTENT'
target_plug_name = 'DEFAULT'
target_embedding_position = lv_position ).
CATCH cx_wd_runtime_repository.
ENDTRY.
wd_this->fire_to_vw_content_plg( param1 = tab ).
Ann.: I my example, I had 3 views: VW_MAIN which embedds VW_SUB. VW_SUB has the tabs in it and VW_SUB embedds VW_CONTENT.
BR,
Roland -
Uploading data from excel file to a dynamically created internal table
Hi,
I have a requirement where i have to upload data from an excel file into a database table. I would be able to determine the structure of the table only at runtime based on the user input.. so i have created an internal table dynamically.
Could you please tell me if its possible to upload data from an excel file to the dynamically created internal table using any function modules?
I thought of doing this by declaring a generic internal table of one field and then uploading the *.csv file into it and then splitting it based on "," and then assigning it to the field symbol referencing the internal table.. but my file length exceeds 132 characters and i'm only able to get data of lenght 132 char's in my internal table ( generic one).
Could anyone please show me a way around this.
Thanks in advance,
HarshaSure, check this out.
report zrich_0002.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: it_fldcat type lvc_t_fcat,
wa_it_fldcat type lvc_s_fcat.
type-pools : abap.
data: new_table type ref to data,
new_line type ref to data.
data: iflat type table of string.
data: xflat type string.
data: irec type table of string with header line.
data: tabix type sy-tabix.
data: file type string.
selection-screen begin of block b1 with frame title text .
parameters: p_file type rlgrap-filename default 'c:Test.csv'.
parameters: p_flds type i.
selection-screen end of block b1.
start-of-selection.
* Add X number of fields to the dynamic itab cataelog
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
append wa_it_fldcat to it_fldcat .
enddo.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
file = p_file.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = file
changing
data_tab = iflat
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
loop at iflat into xflat.
clear irec. refresh irec.
split xflat at ',' into table irec.
loop at irec.
tabix = sy-tabix.
assign component tabix of structure <dyn_wa> to <dyn_field>.
<dyn_field> = irec.
endloop.
append <dyn_wa> to <dyn_table>.
endloop.
* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
Regards,
Rich Heilman -
Passing values to dynamically created internal table
Hi,
I have the flat file data as
f1,f2,f3........so on
where f1 f2 and f3 are field names.
I have a variable var which contains the data
V1,0001,0002.........so on
data: var type string.
The value of field f1 is v1
The value of field f2 is 0001
The value of field f3 is 0002.......so on
FIELD-SYMBOLS: <fs_1> TYPE STANDARD TABLE
I have dynamically created an internal table for fields f1 f2 f3 ...... using
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcatalog
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ASSIGN <fs_data>->* TO <fs_1>.
Now for <fs_1> I have to pass the corresponding values of the fields f1 f2 f3 .
How can i solve this.
Thanks and regards ,
Parvatha ReddyHi,
There is no data in <fs_1>.
I need to pass the data form the string var to the fields of <fs_1>..
I understand that you want to populate the internal table <fs_1>.
for that you fist need work area.. use below statement to create work area..
DATA: new_line TYPE REF TO data.
CREATE DATA new_line LIKE LINE OF <fs_1>.
ASSIGN new_line->* TO <fs_2>.
<fs_2> is not your work aread...
to assign value to each field of you work aread <fs_2>. use statement
ASSIGN COMPONENT 1 OF STRUCTURE <fs_2> TO <fs_3>.
<fs_3> = f1 .
now <fs_3> will point to the first field of work area <fs_2>, f1 is value from your string .. repeat above for each field in workarea, by increasing the component number. Once your work area is filled
append it to table.
append <fs_2> to <fs_1>
apologies if I am not getting the requiremnt correctly.. -
Adding f:Attribute dynamically to a dynamically created Button
Hi ,
I am trying to dynamically create a CommandButton and attach a f:Attribute to the same. But somehow I am not able to get hold of the correct API to do the same -
>RichCommandButton button=new RichCommandButton();
>button.setText("Ok");
>AttributeTag attr=new AttributeTag();
>attr.setValue("DC_OPERATION_BINDING", "bindings.DENY");
>button.getChildren().add(attr);
The issue is that the add method expects a UIComponent and attr is of type com.sun.faces.taglib.jsf_core.AttributeTaggues u can use it like
button.getAttributes().put(DC_OPERATION_BINDING", "bindings.DENY");
{code}
http://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/javax/faces/component/UIComponent.html#getAttributes%28%29 -
Problem in Dynamically create Group ui element
Hi everyone,
I was trying to create group UI element dynamically in Webdynpro ABAP. I was getting Error :Access via 'NULL' object reference not possible.
I have gone through the following procedure
Create component with window and view
In view layout Method: WDDOMODIFYVIEW and done the following code
Source Code
if first_time = ABAP_TRUE.
data:lr_container type REF TO CL_WD_UIELEMENT_CONTAINER,
lr_flowdata TYPE REF TO cl_wd_flow_data,
lr_group TYPE REF TO cl_wd_group,
object type REF TO IF_WD_VIEW_ELEMENT.
CALL METHOD view->get_root_element
receiving
root_view_element = object.
lr_container ?= object.
CALL METHOD cl_wd_group=>new_group
EXPORTING
design = 01
enabled = ABAP_TRUE
has_content_padding = ABAP_TRUE
id = 'GRP1'
view = VIEW
visible = 02
receiving
control = lr_group.
CALL METHOD lr_container->add_child
EXPORTING
the_child = lr_group.
CALL METHOD cl_wd_flow_data=>new_flow_data
EXPORTING
element = lr_group
receiving
control = lr_flowdata.
endif.
To get Group ui element dynamically what i have to do rather than the above code
Thanks in Advance
Sreenivas PHi Sreenivas,
Try to debug and find what line the error occurs and return it to us.
If the error occurs in
CALL METHOD view->get_root_element
receiving
root_view_element = object.
or in
lr_container ?= object.
you will need to check content of object.
Best regards -
Adding AJAX support for dynamically created panelGrid components
Hi everyone!
I would like to ask help from anyone who may have encountered similar problem before...
I have a panelGrid whose component is dynamically created by the backing bean. Here is my JSF code:
<h:panelGrid styleClass="panelGrid"
rowClasses="tsPanelGridRowClass" columns="8" cellpadding="0"
cellspacing="2" bgcolor="transparent" style="margin-left: 10px"
id="revCenterItemPanelGrid"
binding="#{pc_Touchscreen_pull_select_item.revCenterItemPanelGrid}">
</h:panelGrid>And here is the code for backing bean that adds content inside the panelGrid:
HtmlOutputText index = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
index.setId("1");
index.setValue(String.valueOf(1));
index.setStyle("datagridtext");
revCenterItemPanelGrid.getChildren().add(index);On click of a button...
<a4j:commandButton value="Update"
styleClass="commandExButtonPou2" id="button1" reRender="revCenterItemPanelGrid"
actionListener="#{pc_Touchscreen_pull_select_item.doSortActionListener2}">
<f:attribute name="order" value="2"></f:attribute>
<f:attribute name="toggleState" value="off"></f:attribute>
</a4j:commandButton>the backing bean is supposed to update the value of the outputText
doSortActionListener2() {
HtmlOutputText index = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
index.setId("2");
index.setValue(String.valueOf(2));
index.setStyle("datagridtext");
revCenterItemPanelGrid.getChildren().add(index);
}However, update doesn't seem to work. I have been successful in adding ajax support to a panelGrid that is not dynamically created but not for this one.
Has anyone encountered this error before? Any ideas?
Thanks in advance!Hi everyone!
I would like to ask help from anyone who may have encountered similar problem before...
I have a panelGrid whose component is dynamically created by the backing bean. Here is my JSF code:
<h:panelGrid styleClass="panelGrid"
rowClasses="tsPanelGridRowClass" columns="8" cellpadding="0"
cellspacing="2" bgcolor="transparent" style="margin-left: 10px"
id="revCenterItemPanelGrid"
binding="#{pc_Touchscreen_pull_select_item.revCenterItemPanelGrid}">
</h:panelGrid>And here is the code for backing bean that adds content inside the panelGrid:
HtmlOutputText index = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
index.setId("1");
index.setValue(String.valueOf(1));
index.setStyle("datagridtext");
revCenterItemPanelGrid.getChildren().add(index);On click of a button...
<a4j:commandButton value="Update"
styleClass="commandExButtonPou2" id="button1" reRender="revCenterItemPanelGrid"
actionListener="#{pc_Touchscreen_pull_select_item.doSortActionListener2}">
<f:attribute name="order" value="2"></f:attribute>
<f:attribute name="toggleState" value="off"></f:attribute>
</a4j:commandButton>the backing bean is supposed to update the value of the outputText
doSortActionListener2() {
HtmlOutputText index = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
index.setId("2");
index.setValue(String.valueOf(2));
index.setStyle("datagridtext");
revCenterItemPanelGrid.getChildren().add(index);
}However, update doesn't seem to work. I have been successful in adding ajax support to a panelGrid that is not dynamically created but not for this one.
Has anyone encountered this error before? Any ideas?
Thanks in advance! -
How to add a table (dynamic created) into a model attribute
i have dynamically created an internal table. Generally i use model-binding in a stateful MVC-Application.
Is there a possibiltity to transfer the dynamic table to a model. As far as i know generic attributes are not allowed in the modell class.
Every hint welcome
thx in advanceBy some miracle I do have this finally working. I will warn you up front that the code is not the cleanest (I have stuff copied in from all over the place. I probably have lots of unused variable references - but I am running out of time to clean it up further). Also I don't have all the logic to support all your different possible dynamic structure types. I always use SFLIGHT as my dyanmic structure. Therefore you will have to adapt the coding to lookup the actual structure type in use.
So I have a model that has an structure ITAB type ref to data. In my Model initialization I go ahead and dynamically redfine this to my specific type:
METHOD init.
SELECT SINGLE * FROM sflight INTO CORRESPONDING FIELDS OF isflight.
DATA: struct_type TYPE REF TO cl_abap_structdescr,
tabletype TYPE REF TO cl_abap_tabledescr.
struct_type ?= cl_abap_structdescr=>describe_by_name( 'SFLIGHT' ).
CREATE DATA me->itab TYPE HANDLE struct_type.
ENDMETHOD.
Then in my View I have the following:
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="phtmlb" prefix="phtmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form>
<phtmlb:matrix width="100%" >
<%
field-symbols: <wa> type any.
assign model->itab->* to <wa>.
* append initial line to <wa_itab> assigning <Wa>.
data: descriptor type ref to CL_ABAP_STRUCTDESCR.
descriptor ?= CL_ABAP_STRUCTDESCR=>describe_by_data( <wa> ).
data: flddescr type DDFIELDS.
flddescr = descriptor->GET_DDIC_FIELD_LIST( ).
field-symbols: <wa_field> like line of flddescr.
data: label type ref to cl_htmlb_label.
data: input type ref to CL_HTMLB_INPUTFIELD.
data: binding_string type string.
"Loop through each field in the structure Definition
loop at flddescr assigning <Wa_field>.
clear label.
clear input.
concatenate '//model/itab.'
<wa_field>-FIELDNAME
into binding_string.
label ?= cl_htmlb_label=>factory( _for = binding_string ).
input ?= cl_htmlb_inputfield=>factory( _value = binding_string ).
%>
<phtmlb:matrixCell row = "+1"
vAlign = "TOP" />
<bsp:bee bee="<%= label %>" />
<phtmlb:matrixCell col = "+1"
vAlign = "TOP" />
<bsp:bee bee="<%= input %>" />
<%
endloop.
%>
</phtmlb:matrix>
<htmlb:button id="Test" onClick="Test" text="Submit"/>
</htmlb:form>
</htmlb:page>
The key to making this work are custom getter/setters. In your model class, you can copy from the template methods (Like GETM_S_XYZ for the metadata structure method). Copy them and remove the _ on the front of the name. Then change XYZ to the name of the attribute you are binding for. The following are my custom methods.
method get_m_s_itab .
* uses ****************************************************************
* data ****************************************************************
* code ****************************************************************
* method is supposed to return either info about a specific component
* of a structure (component is not initial -> return ref to
* if_bsp_metadata_simple) or the complete structure
* (component is initial -> return ref to if_bsp_metadata_struct)
data: l_attribute_ref type ref to data,
l_attr_ref type ref to data,
l_exception type ref to cx_root,
l_ex type ref to cx_sy_conversion_error,
l_ex_bsp type ref to cx_bsp_conversion_exception,
l_ex2 type ref to cx_bsp_t100_exception,
l_type type i,
l_index type i,
l_name type string,
l_component type string,
l_getter type string.
data: l_field_ref type ref to data,
l_dfies_wa type dfies,
rtti type ref to cl_abap_elemdescr.
data: crap type string,
rest type string,
t_index(10) type c.
split attribute_path at '[' into crap rest.
split rest at ']' into t_index crap.
****Dummy Object to avoid dumps
create object metadata type cl_bsp_metadata_simple
exporting info = l_dfies_wa.
call method if_bsp_model_util~disassemble_path
exporting
path = attribute_path
importing
name = l_name
index = l_index
component = l_component
type = l_type.
data: l_dataref type string.
****Dynamically determine your actual structure - for this demo
****I just hardcode SFLIGHT
concatenate 'SFLIGHT-' l_component into l_dataref.
data: field type ref to data.
****Create a data object of the specified type
try.
create data field type (l_dataref).
catch cx_sy_create_data_error.
exit.
endtry.
rtti ?= cl_abap_typedescr=>describe_by_data_ref( field ).
l_dfies_wa = rtti->get_ddic_field( ).
clear metadata.
create object metadata type cl_bsp_metadata_simple
exporting info = l_dfies_wa.
endmethod.
method get_s_itab .
* uses ****************************************************************
* data ****************************************************************
* code ****************************************************************
* get the given value of the component of the struct, e.g.
* field-symbols: <l_comp> type any.
* assign component component of structure XYZ to <l_comp>.
* value = <l_comp>.
data: l_attr_ref type ref to data,
l_field_ref type ref to data.
data: l_attribute_ref type ref to data,
l_exception type ref to cx_root,
l_ex type ref to cx_sy_conversion_error,
l_ex2 type ref to cx_bsp_t100_exception,
l_type type i,
l_index type i,
l_name type string,
l_component type string,
l_getter type string,
rtti type ref to cl_abap_elemdescr.
field-symbols: <o_data> type any,
<n_data> type any.
*Test
call method if_bsp_model_util~disassemble_path
exporting
path = attribute_path
importing
name = l_name
index = l_index
component = l_component
type = l_type.
* get a field reference for the assignment
field-symbols: <wa> type any,
<l_comp> type any.
assign me->itab->* to <wa>.
assign component l_component of structure <wa> to <l_comp>.
get reference of <l_comp> into l_field_ref.
****Dynamically determine your actual structure - for this demo
****I just hardcode SFLIGHT
data: l_dataref type string.
concatenate 'SFLIGHT-' l_component into l_dataref.
data: field type ref to data.
****Create a data object of the specified type
try.
create data field type (l_dataref).
catch cx_sy_create_data_error.
exit.
endtry.
assign l_field_ref->* to <o_data>.
assign field->* to <n_data>.
move <o_data> to <n_data>.
* call conversion routine
try.
value = if_bsp_model_util~convert_to_string(
data_ref = field
attribute_path = attribute_path
no_conversion_exit = 0 ).
catch cx_sy_conversion_error into l_ex.
me->errors->add_message_from_exception(
condition = attribute_path
exception = l_ex
dummy = value ).
catch cx_bsp_t100_exception into l_ex2.
me->errors->add_message_from_t100(
condition = attribute_path
msgid = l_ex2->msgid
msgno = l_ex2->msgno
msgty = l_ex2->msgty
p1 = l_ex2->msgv1
p2 = l_ex2->msgv2
p3 = l_ex2->msgv3
p4 = l_ex2->msgv4
dummy = value ).
endtry.
endmethod.
method set_s_itab .
* uses ****************************************************************
* data ****************************************************************
* code ****************************************************************
* assign the given value to the component of the struct, e.g.
* field-symbols: <l_comp> type any.
* assign component component of structure XYZ to <l_comp>.
* <l_comp> = value.
data: l_attr_ref type ref to data,
l_field_ref type ref to data.
data: l_attribute_ref type ref to data,
l_exception type ref to cx_root,
l_ex type ref to cx_sy_conversion_error,
l_ex_bsp type ref to cx_bsp_conversion_exception,
l_ex2 type ref to cx_bsp_t100_exception,
l_type type i,
l_index type i,
l_name type string,
l_component type string,
l_getter type string,
rtti type ref to cl_abap_elemdescr.
field-symbols: <o_data> type any,
<n_data> type any.
*Test
call method if_bsp_model_util~disassemble_path
exporting
path = attribute_path
importing
name = l_name
index = l_index
component = l_component
type = l_type.
* get a field reference for the assignment
field-symbols: <wa> type any,
<l_comp> type any.
assign me->itab->* to <wa>.
assign component l_component of structure <wa> to <l_comp>.
get reference of <l_comp> into l_field_ref.
****Dynamically determine your actual structure - for this demo
****I just hardcode SFLIGHT
data: l_dataref type string.
concatenate 'SFLIGHT-' l_component into l_dataref.
data: field type ref to data.
****Create a data object of the specified type
try.
create data field type (l_dataref).
catch cx_sy_create_data_error.
exit.
endtry.
assign field->* to <n_data>.
move <l_comp> to <n_data>.
* call conversion routine
try.
if_bsp_model_util~convert_from_string(
data_ref = field
value = value
attribute_path = attribute_path
use_bsp_exceptions = abap_true
no_conversion_exit = 0 ).
catch cx_sy_conversion_error into l_ex.
me->errors->add_message_from_exception(
condition = attribute_path
exception = l_ex
dummy = value ).
catch cx_bsp_conversion_exception into l_ex_bsp.
me->errors->add_message_from_exception(
condition = attribute_path
exception = l_ex_bsp
dummy = value ).
catch cx_bsp_t100_exception into l_ex2.
me->errors->add_message_from_t100(
condition = attribute_path
msgid = l_ex2->msgid
msgno = l_ex2->msgno
msgty = l_ex2->msgty
p1 = l_ex2->msgv1
p2 = l_ex2->msgv2
p3 = l_ex2->msgv3
p4 = l_ex2->msgv4
dummy = value ).
endtry.
if <n_data> is initial.
clear <l_comp>.
else.
move <n_data> to <l_comp>.
endif.
endmethod.
I know that is a LOT of nasty code without too much explanation. I'm afriad there isn't time right now to expand on how it works too much. Between my day job and trying to finish the BSP book, there just isn't much time left. Like I said before there is a very large section in the book on this topic that hopefully explains it. The book will be out in December or early January - but perhaps I will get some time before then to write up something on SDN about this. -
Appending values to dynamically created fieldsymbol
Hi ,
I have a requirement to append values to dynamically created fieldsymbols
from internal table .
I am using the following code but it dosnt work
<F4> declared as line of <dyn_table>.
loop at it_tab into wa_tab .( this contain the data to be appended to dyn fieldsymbol)
loop at it_fieldcat into wa_fieldcat. ( this contains the fieldnames )
case wa_final_fieldcat-FIELDNAME.
when 'AAA'.
v_field_name = 'AAA.
when 'BBB'.
v_field_name = 'BBB'.
endcase.
ASSIGN COMPONENT v_field_name of STRUCTURE wa_tab to <F4>.
endloop.
append <f4> to <dyn_table>
********************************************8
But only get one value i.e field BBB value appended to
<dyn_table>.
is there any way i can do the append to field symbol looping through internal
table ?
thanks
raji done it in alv so take the part you need .
1) to create dynamic table : CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
also create dynamic fieldcatalog .
2) you can pull data just one time from the DB to dynamic table
so i take the data in regulare it table and in the and i put it
in the dynamic table
hope i help , if you didnt understand some part , say so .
DATA : LT_FCAT TYPE LVC_T_FCAT ,
lo_struct TYPE REF TO data,
LV_STRUC_NAME TYPE TABNAME VALUE 'YMM_ST_TNUOT_MLY'.
REFRESH ls_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = LV_STRUC_NAME
I_BYPASSING_BUFFER = 'X'
CHANGING
CT_FIELDCAT = IT_COLUM_HEADER
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE e402(mo) WITH lv_struc_name.
EXIT.
ENDIF.
DATA INDX(3) .
IF G_COUNETR_NUMBER_OF_KOSTL > 0 .
DO G_COUNETR_NUMBER_OF_KOSTL TIMES.
INDX = SY-INDEX.
SHIFT INDX LEFT DELETING LEADING SPACE.
CONCATENATE 'KOSTL' INDX INTO LS_FCAT-FIELDNAME.
LS_FCAT-INTTYPE = 'I'.
LS_FCAT-COL_POS = 27 + SY-INDEX .
CONCATENATE TEXT-028 INDX INTO LS_FCAT-COLTEXT.
LS_FCAT-OUTPUTLEN = 10.
APPEND LS_FCAT TO IT_COLUM_HEADER.
ENDDO.
ENDIF.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_COLUM_HEADER
IMPORTING
EP_TABLE = GT_TABLE
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
ASSIGN GT_TABLE->* TO <DYN_TABLE>.
*--> Arbeitsbereich dynamisch erzeugen
CREATE DATA LO_STRUCT LIKE LINE OF <DYN_TABLE>.
ASSIGN LO_STRUCT->* TO <WA>.
LOOP AT IT_COLUM_HEADER INTO LS_FCAT.
IF LS_FCAT-FIELDNAME NE 'MANDT'.
ADD 1 TO LS_FCAT-COL_POS.
PERFORM TRANSLATE_HEADER.
MODIFY IT_COLUM_HEADER FROM LS_FCAT.
ENDIF.
ENDLOOP.
============= assigning to dynamic table
DATA : FIELD(10) ,
INDX1(3) .
DATA: WA_DREF TYPE REF TO DATA.
DATA : FS_SUM_GL LIKE LINE OF IT_YMM_ST_TNUOT_MLY.
CREATE DATA LP_DATA LIKE LINE OF <DYN_TABLE>.
ASSIGN LP_DATA->* TO <LS_LINE>.
LOOP AT IT_YMM_ST_TNUOT_MLY.
MOVE-CORRESPONDING IT_YMM_ST_TNUOT_MLY TO <LS_LINE>.
INSERT <LS_LINE> INTO TABLE <DYN_TABLE>.
ENDLOOP .
DATA L_COUNTER_ROLL TYPE I .
LOOP AT <DYN_TABLE> INTO <LS_LINE> .
MOVE-CORRESPONDING <LS_LINE> TO FS_SUM_GL.
CLEAR : FIELD , INDX1 , L_COUNTER_ROLL .
L_COUNTER_ROLL = 1 .
LOOP AT IT_EKKN WHERE EBELN = FS_SUM_GL-EBELN.
AND EBELP = FS_SUM_GL-EBELP.
IF SY-SUBRC = 0 .
INDX1 = L_COUNTER_ROLL.
SHIFT INDX1 LEFT DELETING LEADING SPACE.
CONCATENATE 'KOSTL' INDX1 INTO FIELD .
ASSIGN COMPONENT FIELD OF STRUCTURE <LS_LINE> TO <FS1>.
<FS1> = IT_EKKN-KOSTL .
MODIFY <DYN_TABLE> INDEX SY-TABIX FROM <LS_LINE> .
L_COUNTER_ROLL = L_COUNTER_ROLL + 1 .
ENDIF.
ENDLOOP .
ENDLOOP . -
Dynamically Create Repeater Element in ActionScript
Hi,
I'm trying to dynamically create a repeater control with an
image and a label control. I can do it directly in the MXML file
but when I try and covert it into ActionScript it's not working.
Can anyone see what the problem is with my code?
public function GetPalettes():void{
removeChild(document.FrontPage);
Palettes.method = "GET";
params = {"method": "GetPalettes", "BodyPartNo":
document.PalettesMenu.selectedItem.@partNo};
Palettes.cancel();
Palettes.send(params);
var VerticalBox:VBox = new VBox();
VerticalBox.x = 10;
VerticalBox.y = 10;
VerticalBox.id = "VerticalBox";
var PaletteRepeater:Repeater = new Repeater();
PaletteRepeater.dataProvider =
"{Palettes.lastResult.Palette}";
PaletteRepeater.startingIndex = 0;
PaletteRepeater.id = "PaletteRepeater";
var PaletteImage:Image = new Image();
PaletteImage.setStyle("HorizontalAlign", "left");
PaletteImage.source = "
http://localhost/Flex/Personalised%20Palettes-debug/{PaletteRepeater.currentItem.@PictureS rc}Med.png";
PaletteImage.useHandCursor = true;
PaletteImage.buttonMode = true;
PaletteImage.mouseChildren = false;
PaletteImage.id = "PaletteImage";
var PaletteDescription:Label = new Label();
PaletteDescription.text =
"{PaletteRepeater.currentItem.@Description}";
PaletteDescription.id = "PaletteDescription";
document.MainPage.addChild(VerticalBox);
VerticalBox.addChild(PaletteRepeater);
PaletteRepeater.addChild(PaletteImage);
PaletteRepeater.addChild(PaletteDescription);
Thanks"katychapman85" <[email protected]> wrote in
message
news:[email protected]...
> Hey Amy,
>
> I've put a thread up about this but thought I'd ask you
as well as you've
> been
> a great help to me so far.
>
> I have this function:
> public function GetOptions(Menu:int):void{
> document.MenuOptions.url =
> "
http://localhost/Flex/Personalised%20Palettes-debug/MenuOptions.php?Menu=";
> document.MenuOptions.url += Menu;
> document.MenuOptions.send();
> }
>
> What I'm trying to do is when a user clicks on a Radio
button this
> function is
> called and the number of the Menu required is sent to
the function.
>
> I've added this Event Listener to my Radio Button:
>
>
document.RadioButtons2.addEventListener(MouseEvent.CLICK,
> function():void{GetOptions(2);});
>
> However, it's not working. Everything I've read suggests
using an
> anonymous
> function in the Event Listener to pass the menu
parameter but for some
> reason
> it's not working.
What version of Flex are you using? The Help for Flex 3 has
this to say:
http://www.adobe.com/livedocs/flex/3/html/help.html?content=events_05.html
Defining event listeners inline
The simplest method of defining event handlers in Flex
applications is to
point to a handler function in the component's MXML tag. To
do this, you add
any of the component's events as a tag attribute followed by
an ActionScript
statement or function call.
You add an event handler inline using the following syntax:
<mx:tag_name event_name="handler_function"/>
For example, to listen for a Button control's click event,
you add a
statement in the <mx:Button> tag's click attribute. If
you add a function,
you define that function in an ActionScript block. The
following example
defines the submitForm() function as the handler for the
Button control's
click event:
<mx:Script><![CDATA[
function submitForm():void {
// Do something.
]]></mx:Script>
<mx:Button label="Submit" click="submitForm();"/>
Event handlers can include any valid ActionScript code,
including code that
calls global functions or sets a component property to the
return value. The
following example calls the trace() global function:
<mx:Button label="Get Ver" click="trace('The button was
clicked');"/>
There is one special parameter that you can pass in an inline
event handler
definition: the event parameter. If you add the event keyword
as a
parameter, Flex passes the Event object and inside the
handler function, you
can then access all the properties of the Event object.
The following example passes the Event object to the
submitForm() handler
function and specifies it as type MouseEvent:
<?xml version="1.0"?>
<!-- events/MouseEventHandler.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.controls.Alert;
private function myEventHandler(event:MouseEvent):void {
// Do something with the MouseEvent object.
Alert.show("An event of type '" + event.type + "'
occurred.");
]]></mx:Script>
<mx:Button id="b1" label="Click Me"
click="myEventHandler(event)"/>
</mx:Application>
It is best practice to include the event keyword when you
define all inline
event listeners and to specify the most stringent Event
object type in the
resulting listener function (for example, specify MouseEvent
instead of
Event).
You can use the Event object to access a reference to the
target object (the
object that dispatched the event), the type of event (for
example, click),
or other relevant properties, such as the row number and
value in a
list-based control. You can also use the Event object to
access methods and
properties of the target component, or the component that
dispatched the
event.
Although you will most often pass the entire Event object to
an event
listener, you can just pass individual properties, as the
following example
shows:
<?xml version="1.0"?>
<!-- events/PropertyHandler.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.controls.Alert;
private function myEventHandler(s:String):void {
Alert.show("Current Target: " + s);
]]></mx:Script>
<mx:Button id="b1" label="Click Me"
click="myEventHandler(event.currentTarget.id)"/>
</mx:Application>
Registering an event listener inline provides less
flexibility than using
the addEventListener() method to register event listeners.
The drawbacks are
that you cannot set the useCapture or priority properties on
the Event
object and that you cannot remove the listener once you add
it.
don't see anything in there about anonymous functions...?
Maybe you are looking for
-
Itunes was unable to load provider date from sync services
When installing/using iTunes for one of our users received above message. After some investigation (and having followed up other suggestions) I finally tracked the problem down to the 'Application Data' folder being redirected through Windows Server
-
I have a new Macbook pro, I cannot get past the country selection screen. 'Continue' is greyed out and keys just make error sounds. How do I move it on?
-
How to fetch iView Properties within a Role?
Hi, I have Role-A. PCD path of this role is known. With this information, programmatically I should be able to fetch a few properties of all the iViews within this Role. An iView can be at any level with in this Role-A ( like RaleA- Workset-Page-
-
Firefox has created thousands of bookmarks, sync is slow, FF is slow, FF freezes
I can't delete bookmarks by the traditional means since it freezes FF. I need to mass delete these bookmarks AND I need to purge my new FF Sync account. How can I do that? The old sync allowed you to purch bookmarks in the cloud. The large amount of
-
Hi, We have a Checkpoint Firewall using ACS for authentication with RADIUS protocol. We have two ACS servers configured as primary and secondary on the Checkpoint. Both the ACS servers are configured to use AD as the external database. Checkpoint is