Accessing public properties/methods of flash component
I've been searching all day trying to figure out how I can go about accessing properties decalared with in a flash component or containers base actionscript class.
I need to create a fairly complex interface within a part of a flex web app and I think it would be better to create it in flash profressional. I just cannot find any good information on how to get xmxl/flex to play nicely with swf/swc. Maybe it's justs not possible.
Any help or even a point in the right direction would be greatly appreciated.
So I ended up answering my own question, but thought I would share how I did it since I can't seem to find any instructions or examples anywhere.
So what I wanted in the end was a swc file running within my flex app but I need to be able to pull data out of my swc for use with in flex. These are the steps I took to get there. If you read through this and feel there is a better way of achieving the end result please share.
Start out by adding a Flash Professional Container to your FLEX project (I dont know the difference between Component and Container, all I figured out is Component would blow up when I started adding classes with the Flash Professional project)
Give the Container and ID. mine is myTest
Double click and open the Container with in Flash Professional
Once in Flash Professional go to the Library tab and right click to add a new Symbol.Make it a MovieClip and name it what ever you would like and export it for Actionscript. **I have yet to add more to this but I plan on treating this as my "Stage" or base view.
Once created drag a new instance into the view. Make sure it is at 0,0 and give it a instance name. You will use this name as your accessor in FLEX
Right click on your new movie clip in the Library tab and selecet edit class. since all I wanted was a string I created a private string and its public getter method
private var _dataString:string = "Some string of data";
public function get dataString():String {
return _dataString;
Save your class and close it
Click the Done button in the .fla window to save your Flash project and return to Flash Builder.
Now with in the actionscript section of my MXML I can access the string above by myTest.appMain.dataString; appMain is the instance name of the movieclip I created in Flash Professional.
Now that I figured this out it seems so trival and shouldnt have taken me so long to figure out. I'm just surprised I couldn't find more info on the web about getting Flash components/containers to work well with in Flex/Flash Builder.
I hope this helps someone out.
Similar Messages
-
Accessing public JApplet method from javascript
Hi,
I am currently trying to invoke a public method coded in a swing applet from my javascript.
As per the documentation and discussion at this site,tried to workaround by using document.AppletName.MethodName.
I am using Javaplugin 1.2.2 and an Object tag (not an applet tag)
I am getting "object not found' error on running it.
Any possible suggestions as to why its happening?Hi,
You have to set the scriptable property to true in the object tag. I have included a sample object tag here below. Just change the applet name and applet class name. It has surely worked for me.For more details mail me : [email protected]
<OBJECT classid="clsid:E19F9330-3110-11d4-991C-005004D3B3DB" name="AppletName");
WIDTH ="200" HEIGHT ="250" codebase="http://java.sun.com/products/plugin/1.3.0_01/jinstall-130_01-win32.cab#Version=1,3,0,1"
<PARAM NAME = CODE VALUE = AppletName.class ><PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.0_01">
<PARAM NAME="scriptable" VALUE="true">
<EMBED type="application/x-java-applet;jpi-version=1.3.0_01" name="AppletName" CODE = AppletName.class WIDTH ="200" HEIGHT ="250" scriptable=true pluginspage="http://java.sun.com/products/plugin/1.3.0_01/plugin-install.html">
<NOEMBED></EMBED></OBJECT> -
Access of undefined method/property through reference with a static type Class
I get the following error: (it's not word for word but you get the idea)
Error: Access of undefined method getStatus through reference with a static type Class.
Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
package com.mypackage
import flash.display.*;
public class User extends Sprite
public var mainStatus:int;
public function User()
trace("User Created!");
mainStatus = 0;
public function setStatus(status:int):void
mainStatus = status;
public function getStatus():int
return mainStatus;
Ok, so far so good.
now I created a new .fla file under the root of /flash_working/. The class file is in /com/mypackage/User.as
in my .fla file I have:
import com.mypackage.User;
var myUser:User = new User();
var i = User.getStatus();
trace(i);
That's all the code I have. Could someone please explain why it's giving me that error?
If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
Error: Access of undefined property mainStatus through reference with a static type Class.
Thanks for any help!
jef3189the public getStatus() function that you created needs to be referred to through an instance of the class.
So:
import com.mypackage.User;
var myUser:User = new User();
var i = myUser.getStatus();
trace(i);
Also, an aside. You can create a getter/setter for status, to avoid having to do the function as such.
package com.mypackage
import flash.display.*;
public class User extends Sprite
public var mainStatus:int;
public function get status():int
return mainStatus;
public function set status(value:int):void
mainStatus = value as int;
public function User()
trace("User Created!");
mainStatus = 0;
And then, you can call it as:
import com.mypackage.User;
var myUser:User = new User();
trace(myUser.status);
EDIT
I just noticed that you made the variable public as well, which means you can access it without getter/setter or function.
import com.mypackage.User;
var myUser:User = new User();
trace(myUser.mainStatus); -
Accessing portal service from abstract portal component
Hi
I have created a portal service where it contains getdata() and putdata(String) methods.
I have created a abstract portal component and trying to access the portal service from this component.
In portalapp.xml file of the portal component i have created the sharing reference and i have given the service name.
When i run the component it says service not found.
Please let me know if i have missed some things
Thanks and Regards
NagaKishoreHi Prakash
Sorry for the latereply.
find below the code for the interface
package com.sap.global;
import com.sapportals.portal.prt.service.IService;
public interface IGlobalContext extends IService
public static final String KEY = "IGlobalContext.GlobalContext";
public void putData(String strUserID,String strSessionID);
public String getData();
portalapp.xml file of the portal service.
<application>
<application-config/>
<components/>
<services>
<service name="GlobalContext">
<service-config>
<property name="className" value="com.sap.global.GlobalContext"/>
<property name="startup" value="true"/>
</service-config>
<service-profile>
<property name="Test" value="true"/>
</service-profile>
</service>
</services>
</application>
I am doing the following steps to access the portal service in the abstract portal component.
1. Add the portal service to the java build path of the abstract portal component.
2. do content method has the following code.
String userid ="",sessionid="";
response.write("Welcome");
try
IUserContext uc= request.getUser();
userid = uc.getLogonUid();
sessionid = request.getServletRequest().getSession().toString();
response.write("Iview "+userid);
IGlobalContext uid = (IGlobalContext)PortalRuntime.getRuntimeResources().getService(IGlobalContext.KEY);
uid.putData(userid,sessionid);
response.write(" Response from Service " + uid.getData());
}catch (Exception e)
response.write(e.toString());
3. portalapp.xml of abstract portal component
<application>
<application-config>
<property name="SharingReference" value="GlobalContext"/>
</application-config>
<components>
<component name="LandingPageComponent">
<component-config>
<property name="ClassName" value="com.satyam.landing.LandingPage"/>
</component-config>
<component-profile/>
</component>
</components>
<services/>
</application>
I am getting the following error.
Portal Runtime Error
An exception occurred while processing a request for :
iView : N/A
Component Name : N/A
Could not find portal application GlobalContext.
Exception id: 11:53_08/04/05_0095_1641450
See the details for the exception ID in the log file
Thanks in advance
Regards
NagaKishore -
Javascript enabling and using JS methods on TextEdit component
Hello Friends:
I am working to display data using TableView component.
In each row, one of the cell contains a group of radio
buttons and an other cell contains TextEdit component.
For an event on the group of radio buttons, the TextEdit
should flip editable to non-editable and vice-versa.
I am using the TextEdit attribute method,
<b>setJsObjectNeeded(true)</b>
to expose the JavaScript methods of the component.
I am using the following bits of code for accessing the
TextEdit JavaScript functionality.
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var text_edit_comp = eval(func(id_of_textedit));
<b>text_edit_comp.setEnabled()</b>;
Whole thing works as planned, but it is not possible to
disable or enable the TextEdit component using the
JavaScript, as shown above.
In the portal documentation, the JavaScript object
methods were mentioned only for certain components, NOT
including TextEdit !!
If I replace TextEdit with InputField, it works perfectly
as like needed.
How to hack it to work for TextEdit ?
Thank you very much for your kind answers.
Prasad NutalapatiI did use the suggestion. No use.
When I say,
var textedit = eval(func("<id-of-the-textedit-from-java"));
I am getting the object reference.
When I say,
<b>var id = textedit.id;
var elem = document.getElementById(id);</b>
I am getting the HTML name/id and object of the text edit.
Now when I use JS methods and properties,
alert("type="+elem.type);
alert("name="+elem.name);
I get them back correctly.
Then when I say,
<b>alert("disable ?"+ document.forms[0].elements[elem.name].disabled;</b>
I am getting answer as 'false' which is not correct. It
is initially disabled, when I defined with Java.
And subsequently, when I say,
<b>document.forms[0].elements[elem.name].disabled = false;</b>
It didn't affect it at all.
If I try to use the JS methods provided by Portal, like..
<b>textedit.setEnabled();</b>
It is giving an JS error saying that the object doesn't
have that method. -
Attempted access of inaccessible method
Attempted access of inaccessible method I cant see the problem as I pass a class with a mesh property .
I am using AS3 and away3D. Everything loads fine .
Description Resource Path Location Type
1195: Attempted access of inaccessible method enemyMesh through a reference with static type ClassEnemyCube.
public function moveForward(amt:int,models:Array):void
var enemyMesh2:Mesh;
for each (var el:ClassEnemyCube in models)
enemyMesh2=el.enemyMesh(); //error
calls this property
public function get enemyMesh():Mesh
return model5;
}Syntax for accessors (getters and setters) is the same as for properties. So, you loop must be:
for each (var el:ClassEnemyCube in models)
enemyMesh2 = el.enemyMesh;
Not - there are no parenthesis attached to enemyMesh. -
How to modify a java method in Folder component
Hi,
I need to add some custom java code after a java method in Folder component (I am using UCM 10g, the java method is "buildResultSet" in service "COLLECTION_COPY_LOT").
I defined service handler as described in Bex's book. My static table is:
<@table custom_ServiceHandler@>
<tr>
<td>serviceName</td><td>handler</td><td>searchOrder</td>
</tr>
<tr>
<td>Service</td><td>myPackage.MyClass</td><td>1</td>
</tr>
</table>
Java code is :
package myPackage
public class MyClass extends ServiceHandler {
public void buildResultSet() trows DataException,ServiceException
............. mu custom code
m_service.doCodeEx("",this);
If a change java method to addFiles and in static table Service to DocService, when i execute Checkin_new service it executes my custom code. I tried to change to loadorder, but have no success.
Pls someone to tell me how can i modify this method or any other java method in "COLLECTION_COPY_LOT" service. Do i have to make some additional settings ? What other ways to modify java methods i should try ?
I hope someone who has done someything like this to help me out.
Thanks in advanceA service handler might be the right way to run some code at the end of a service call (another way would be to make use of filters).
First, make sure your static table is merged with ServiceHandlers.
Secondary, change your custom method name into one that is not already in the service definition of COLLECTION_COPY_LOT (preferably a unique method name like collectionCopyLotLastAction that describes its purpose) and remove the following line from your code:
m_service.doCodeEx("",this);Now create a service definition for COLLECTION_COPY_LOT in your custom component based on the original COLLECTION_COPY_LOT (copy paste from the original service definition) and add you own method collectionCopyLotLastAction as the last step in the service. Play with the load order to make sure CS is using your service definition of COLLECTION_COPY_LOT instead of the original.
regards,
Fabian -
ALV - access to protected method
Hello,
I have a object from class "CL_GUI_ALV_GRID" and want to change the protected attribute "EVT_DELAYED_CHANGE_SELECTION Constant Protected" with the method
CALL METHOD alv_grid->SET_DELAY_CHANGE_SELECTION
EXPORTING
time = lv_delay.
How can I access this protected attribute?
Thanks in advance,
HolgerThis will do what you want
Trick is to define a sub class inheriting the super class where the protected attributes and methods exist in - then you can access the protected methods and attributes.
If you do this don't forget to call the SUPER CONSTRUCTOR (of the class you are inheriting from) in your constructor method. Code example shown below.
Here I want the original and modified table of an alv grid but you can adapt this code to whatever you need.
Hope it helps.
create blank screen (100) with a custom container CCONTAINER1 and the following scren logic in it
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
now look at the code here. Note text in Bold
PROGRAM zdynfieldcat.
class zcltest definition deferred. "For field symbol reference.
Simple test of dynamic ITAB with user defined (not ddic) fields
Build dynamic fcat
Table structure obtained via new RTTI functionality
use ALV grid to display and edit.
Create a blank screen 100 with a custom container called CCONTAINER1.
James Hawthorne
Define field symbols as these can't be defined in classes
field-symbols: <dyn_table> type standard table,
<g2> type ref to zcltest,
<g1> type ref to cl_gui_custom_container,
<actual_tab> type standard table,
<outtab> type table,
<fs1> type ANY,
<FS2> TYPE TABLE,
<fs3> type table,
<fs4> type table,
<fs5> type table.
<b>class zcltest definition inheriting from cl_gui_alv_grid.
define this as a subclass so we can access the protected attributes
of the superclass cl_gui_alv_grid</b>
public section.
types: g4 type ref to cl_gui_custom_container.
types: g3 type ref to cl_alv_changed_data_protocol.
data: i_parent type g4,
lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
zog like line of lr_rtti_struc->components. "RTTI
types: struc like zog.
types: struc1 type table of struc.
methods:
constructor
importing i_parent type g4,
disp_tab
importing p_er_data_changed type g3,
create_dynamic_fcat
importing zogt type struc1
exporting it_fldcat type lvc_t_fcat.
Protected section.
data: stab type ref to data,
wa_it_fldcat type lvc_s_fcat,
c_index type sy-index.
endclass.
<b>class zcltest implementation.
METHOD constructor.
CALL METHOD super->constructor
EXPORTING
i_appl_events = 'X'
i_parent = i_parent.
endmethod
method disp_tab.
*mt_outtab is the data table held as a protected attribute
in class cl_gui_alv_grid.
assign me->mt_outtab->* TO <outtab>. "Original data
assign p_er_data_changed->mp_mod_rows TO <FS1>.
stab = p_er_data_changed->mp_mod_rows.
assign p_er_data_changed->mt_inserted_rows to <fs3>.
assign p_er_data_changed->mt_deleted_rows to <fs4>.
assign p_er_data_changed->mt_mod_cells to <fs5>.
assign stab->* TO <fs2>.
do whatever you want with <outtab>
contains data BEFORE changes each time.
Note that NEW (Changed) table has been obtained already by
call to form check_data USING P_ER_DATA_CHANGED
TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
Entered data is in table defined by <fs2>
In this method you can compare original and changed data.
Easier than messing around with individual cells.
do what you want with data in <fs2> validate / update / merge etc
endmethod.</b>
method create_dynamic_fcat.
loop at zogt into zog.
c_index = c_index + 1.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
if c_index eq 2.
wa_it_fldcat-emphasize = 'C411'.
endif.
if c_index eq 3.
wa_it_fldcat-emphasize = 'C511'.
endif.
append wa_it_fldcat to it_fldcat .
endloop.
endmethod. "create_dynamic_fcat
endclass. "zcltest IMPLEMENTATION
class lcl_grid_event_receiver definition.
public section.
methods:
handle_data_changed
for event data_changed of zcltest
for event data_changed of cl_gui_alv_grid
importing er_data_changed,
toolbar
for event toolbar of zcltest
importing e_object
e_interactive,
user_command
for event user_command of zcltest
importing e_ucomm.
endclass.
class lcl_grid_event_receiver implementation.
method handle_data_changed.
code whatever required after data entry.
various possibilites here as you can get back Cell(s) changed
columns or the entire updated table.
Data validation is also possible here.
call method <g2>->disp_tab
EXPORTING
p_er_data_changed = er_data_changed.
endmethod. "handle_data_changed
method toolbar.
data : ls_toolbar type stb_button.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'EDIT' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move 'Edit' to ls_toolbar-text.
move icon_change_text to ls_toolbar-icon.
move 'Click2Edit' to ls_toolbar-quickinfo.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'UPDA' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move 'Update' to ls_toolbar-text.
move icon_system_save to ls_toolbar-icon.
move 'Click2Update' to ls_toolbar-quickinfo.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 0 to ls_toolbar-butn_type.
move 'EXIT' to ls_toolbar-function.
move space to ls_toolbar-disabled.
move 'Exit' to ls_toolbar-text.
move icon_system_end to ls_toolbar-icon.
move 'Click2Exit' to ls_toolbar-quickinfo.
append ls_toolbar to e_object->mt_toolbar.
endmethod. "toolbar
method user_command.
case e_ucomm .
when 'EDIT'. "From Tool bar
perform set_input.
perform init_grid.
when 'UPDA'. "From Tool bar
perform refresh_disp.
perform update_table.
when 'EXIT'. "From Tool bar
leave program.
endcase.
endmethod. "user_command
endclass. "lcl_grid_event_receiver IMPLEMENTATION
program data
include <icon>.
define any old internal structure NOT in DDIC
types: begin of s_elements,
anyfield1(20) type c,
anyfield2(20) type c,
anyfield3(20) type c,
anyfield4(20) type c,
anyfield5(11) type n,
end of s_elements.
data: wa_element type s_elements,
wa_data type s_elements.
Note new RTTI functionality allows field detail retrieval
at runtime for dynamic tables.
data:
grid1 type ref to zcltest,
grid_handler type ref to lcl_grid_event_receiver,
c_dec2 type s_elements-anyfield5,
wa_it_fldcat type lvc_s_fcat,
it_fldcat type lvc_t_fcat,
lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
ls_comp LIKE LINE OF lt_comp, "RTTI
zog like line of lr_rtti_struc->components, "RTTI
struct_grid_lset type lvc_s_layo,
l_valid type c,
new_table type ref to data.
types: struc like zog.
data: zogt type table of struc,
grid_container1 type ref to cl_gui_custom_container,
g_event_receiver type ref to lcl_grid_event_receiver,
ok_code like sy-ucomm,
i4 type int4.
start-of-selection.
call screen 100.
module status_0100 output.
if grid_container1 is initial.
create object grid_container1
exporting
container_name = 'CCONTAINER1'.
assign grid_container1 to <g1>.
create object grid1
exporting i_parent = grid_container1.
we need reference to this instance so we can use
Methods etc of zcltest class and alv (superclass)
in our event receiver class.
assign grid1 to <g2>.
create object grid_handler.
set handler:
grid_handler->user_command for grid1,
grid_handler->toolbar for grid1,
grid_handler->handle_data_changed for grid1.
Get the Internal table structure
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
Build field catalog just use basic data here
colour specific columns as well
zogt[] = lr_rtti_struc->components.
call method grid1->create_dynamic_fcat
EXPORTING
zogt = zogt
IMPORTING
it_fldcat = it_fldcat.
Create dynamic internal table and assign to field symbol.
Use dynamic field catalog just built.
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>.
perform populate_dynamic_itab.
perform init_grid.
perform register_enter_event.
set off ready for input initially
i4 = 0.
call method grid1->set_ready_for_input
EXPORTING
i_ready_for_input = i4.
endif.
endmodule. "status_0100 OUTPUT
module user_command_0100 input.
*PAI not needed in OO ALV anymore as User Commands are handled as events
*in method user_command.
*we can also get control if the Data entered and the ENTER is pressed by
*raising an event.
Control then returns to method handle_data_changed.
endmodule. "user_command_0100 INPUT
form populate_dynamic_itab.
load up a line of the dynamic table
c_dec2 = c_dec2 + 11.
wa_element-anyfield1 = 'Tabbies'.
wa_element-anyfield2 = 'ger.shepards'.
wa_element-anyfield3 = 'White mice'.
wa_element-anyfield4 = 'Any old text'.
wa_element-anyfield5 = c_dec2.
append wa_element to <dyn_table>.
endform. "populate_dynamic_itab
form exit_program.
call method grid_container1->free.
call method cl_gui_cfw=>flush.
leave program.
endform. "exit_program
form refresh_disp.
call method grid1->refresh_table_display.
endform. "refresh_disp
form update_table.
The dynamic table here is the changed table read from the grid
after user has changed it
Data can be saved to DB or whatever.
loop at <dyn_table> into wa_element.
do what you want with the data here
endloop.
switch off edit mode again for next function
i4 = 0.
call method grid1->set_ready_for_input
EXPORTING
i_ready_for_input = i4.
endform. "update_table
form set_input.
i4 = 1.
call method grid1->set_ready_for_input
EXPORTING
i_ready_for_input = i4.
endform. "set_input
form switch_input.
if i4 = 1.
i4 = 0.
else.
i4 = 1.
endif.
call method grid1->set_ready_for_input
EXPORTING
i_ready_for_input = i4.
endform. "switch_input
form init_grid.
Enabling the grid to edit mode,
struct_grid_lset-edit = 'X'. "To enable editing in ALV
struct_grid_lset-grid_title = 'Jimbos Test'.
call method grid1->set_table_for_first_display
EXPORTING
is_layout = struct_grid_lset
CHANGING
it_outtab = <dyn_table>
it_fieldcatalog = it_fldcat.
endform. "init_grid
form register_enter_event.
call method grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
Instantiate the event or it won't work.
create object g_event_receiver.
set handler g_event_receiver->handle_data_changed for grid1.
endform. "register_enter_event -
The documentation for Flash Builder 4 beta says that after opening flash from flash builder, I should click a "done" button in flash and flash should close and what I created in flash should be included as a component or container in Flash Builder. Using the Flash Builder 4 beta on Windows, when I click on the "create in flash" button on the properties panel for either the new flash component or container, Flash CS4 opens, I create something in Flash and no "done" button is present. Nor is anything present in the menus resembling a "done" option. Where is it?
Hi Jeffrey:
Still no done button. Now under commands in Flash I can convert symbols to flex components and containers and these show up in the Flash library.
Thanks:
Jim
Date: Wed, 30 Sep 2009 09:58:10 -0600
From: [email protected]
To: [email protected]
Subject: Where is the "done" button in Flash CS4 when using Flash Builder 4's new flash component or container?
Hi,
You may need to install FlexComponentKit.mxp to your Flash CS4 beforehand.
Jeffrey
Date: Tue, 29 Sep 2009 17:04:36 -0600
From: mailto:[email protected]
To: mailto:[email protected]
Subject: Flex Where is the "done" button in Flash CS4 when using Flash Builder 4's new flash component or container?
I apparently didn't get one. I've looked under various workspace configurations. Another thing that seems odd is that when Flash opens I get the opening panel that allows me to select the type of file and version of AS I want to use. I select new file with AS3. Any ideas on why the "done" button wouldn't be present and if the opening panel is what I should expect on opening Flash after clicking the "create in Flash" button?
>
> -
Sizing a Scene7 flash component
Does anyone know how to size a flash component? I am using the BasicZoom and Flash Flyout Zoom. Both seem to have a ton of unnecessary whitespace around them. I've seen smaller examples, but I haven't been able to figure out how to size them as cq:includes
thanksThe solution I came up with was to override the component and add properties to adjust the size of the Flash canvas and the viewport.
-
Having problem access the EJB 3 from Web Component
Hi ,
I have an EJB 3 entity AuctionItem and a session ItemProcessor only implements the local interface IItemProcessor, then I use a servlet to access the findAll method in the ItemProcessor. I've created a Enterprise Applicaiton project to contain the ejb jar and the war file, but after I deploy the ear successfully, I couldn't access to my servlet through http://localhost:8080/AuctionWeb/AuctionServlet, it keeps giving me error like follwoing. Do you know why, your help will be very appreciated !
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
at web.AuctionServlet.doGet(AuctionServlet.java:43)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
My code sample:
public class AuctionServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
@EJB
private IItemProcessor itemProcessor;
public AuctionServlet() {
super();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet AuctionServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet AuctionServlet at " + request.getContextPath () + "</h1>");
List items = itemProcessor.findAll();
for (Iterator it = items.iterator(); it.hasNext();) {
AuctionItem elem = (AuctionItem) it.next();
out.println(" <b>"+elem.getItemid()+" </b><br />");
out.println(elem.getTitle()+"<br /> ");
out.println("</body>");
out.println("</html>");
.....And the session bean is :
package sessions;
import javax.annotation.Resource;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.*;
import javax.sql.DataSource;
import java.util.List;
import entities.AuctionItem;
@Stateless(name = "ItemProcessor")
public class ItemProcessor implements sessions.IItemProcessor {
@PersistenceContext
EntityManager entityManager;
public Long createItem(String title, Double value, String description,
String status) {
AuctionItem item = new AuctionItem();
item.setTitle(title);
item.setValue(value);
item.setDescription(description);
item.setStatus(status);
entityManager.persist(item);
return item.getItemid();
public String findItemByKey(Long id) {
AuctionItem item = entityManager.find(AuctionItem.class, id);
return item.getTitle();
public List findAll() {
return entityManager.createQuery("select object(o) from AuctionItem as o").getResultList();
}The most common reason for this failure is if your web.xml does not refer to the latest web application
.xsd :
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http
://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/x
ml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Otherwise, the web application is considered to be a J2EE 1.4 application and annotations
are not processed. If that's not the case you can also run the application through the
verifier to see if it identifies any issues. -
Access to protected method is ot allowed
Hi,
there is class with a protected method. I get the message
"Access to protected method is ot allowed"
How must such methods be called if they are protected ?
Regards
sasErdem, please try to post in the correct forum. ABAP Objects questions belong in this forum, not general.
Second, Amit Khare is correct. The concept of Public/Protected/Private methods and attributes is not limited to ABAP Objects. It is a common concept to most object oriented programming languages. But if your read the ABAP Help on the appropriate keywords, then it is explained very clearly.
matt -
How to access a proctected method of a class
Hi All,
I have the below code where in the idents_get is a protected method of the class.so when i activate it is throwing an error, method is unkown or protected or private.
data: gv_class TYPE REF TO /tdag/cpcl_decl_sub_view_ctrl.
create object gv_class.
CALL METHOD gv_class->idents_get
EXPORTING
i_estcat = gc_estcat6
i_pos_wanted = 1
IMPORTING
et_idents = lt_idents
changing
xt_recns = li_recn
EXCEPTIONS
read_failed = 1
others = 2.
i know protected methods can be accessed in derived class.
I'm new to ABAP oops concepts please give me some pointers to access a protected method.
or any sample code to access protected method.
Thanks in advance,
Srilakshmi.Hello Srilakshmi
You can access protected methods WITHIN an instance of the class or WITHIN an instance of a sub-class.
However, in your case you are calling the method from the report and, therefore, the class must be PUBLIC.
Regards
Uwe -
Error in accessing the create method declared in Home interface
hi,
I have create method in home interface which takes the following syntax:
public ShipRemote create(ShipPK id,String name,int capacity,float tonnage) throws CreateException,RemoteException;
In the client I create a remote object and try to call this create method, but I get a compilation error :
it says unable to resolve the symbol with a cursor pointing the create method
interface sampleEJB.ship.shipInfo.ShipHome ShipRemote remoteRef=(ShipRemote)homeRef.create(spk,sname,5000,100.7);
how can i resolve this.
I have implemented this create method in my beanhi i have compiled the client interfaces and the bean successfully.
I have also imported the classes in the in the client code .
I even deployed my jar successfully, but i have problem in accessing the create method specified .
thank you -
How can access every item on a HorizontalList Component
Hi,
I would like to know how can I access every item on a HorizontalList component. What I want to do is something like this:
My HorizontalList:
<mx:HorizontalList
bottom="0"
backgroundAlpha="0.0"
id="catalogoOpciones"
columnCount="3"
height="80"
hideEffect="{esconderse}"
horizontalScrollPolicy="on"
selectable="false"
showEffect="{mostrarse}"
width="100%">
<mx:itemRenderer>
<mx:Component>
<mx:VBox height="100%" verticalGap="0" horizontalAlign="center">
<mx:Label id="titulo" text="{data.nombre}" textAlign="center" styleName="nombreOpcionDetallePlato" />
<mx:ComboBox id="seleccion" dataProvider="{data.opciones}" labelField="label" labelFunction="funcionLabelComboBox" styleName="comboOpcionDetallePlato" change="dispatchEvent(new Event('cambioOpcion',true))"/>
<mx:Script>
<![CDATA[
public function funcionLabelComboBox(item:Object):String {
return item.label + ", $" + item.precio;
]]>
</mx:Script>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:HorizontalList>
What I want to do is to show on an Alert screen the selected index in every ComboBox on the horizontallist:
for(var i:Number=0;i<horizontalListt.dataProvider.length;i++){
var indice:Number = (horizontalListt.dataProvider.getChildAt(i) as ComboBox).selectedIndex;
Alert.show(indice.toString());
I must add, that the horizontalList is working just fine, the only thing that's giving me problems is the access to every item in the list.
Thank you very much for your time and help.
Sebastián Toro O.Greg, thank you for your quick response, but your answer is a little ambiguous for me. How can my dataProvider change when the user selects another index? the itemRenderer it's supposed get the information off the dataProvider to fill its ComboBoxes, but when the user selects another index, that change shouldn't have any effect on the dataProvider.
remember that the itemRenderer is:
<mx:itemRenderer>
<mx:Component>
<mx:VBox height="100%" verticalGap="0" horizontalAlign="center">
<mx:Label id="titulo" text="{data.nombre}" textAlign="center" styleName="nombreOpcionDetallePlato" />
<mx:ComboBox id="seleccion" dataProvider="{data.opciones}" labelField="label" labelFunction="funcionLabelComboBox" styleName="comboOpcionDetallePlato" change="dispatchEvent(new Event('cambioOpcion',true))"/>
<mx:Script>
<![CDATA[
public function funcionLabelComboBox(item:Object):String {
return item.label + ", $" + item.precio;
]]>
</mx:Script>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
So what I whant to access, is every Component that the itemRenderer created:
Alert.show(((catalogoOpciones.dataProvider.getItemAt(0) as VBox).getChildByName("seleccion") as ComboBox).selectedIndex.toString());
I want to get the selectedIndex of the ComboBox of the First Item that was created on the HorizontalList. I thought the last line of code would do the trick but it doesn't. Could you be more specific please?
Thanks again
Sebastián Toro O.
PS:don't worry that if you answer my question you'll get the 10 pts
Maybe you are looking for
-
How to import a video from a DVD
I'm trying to edit a video that was created and put on a DVD. The video plays but I can't seem to import the video into iMovie for editing. What do I do to get this video into iMovie?
-
Hi Regarding Report Painter/Writer
Hi All, I am new to the Report Painter/Writer concepts. I got an object based on this concept. Can you help me where i can get the material on Report Painter/Writer. and what are the important Tcodes used in Report Painter/Writer. Already i had some
-
"block change tracking" equivalent in sql server
Hi All, If someone has expertise in both oracle and sql server, pls let me know if there is " block change tracking" equivalent in sql server. I know sql server has incremental/differential backup, curious to know whether it got this equivalent featu
-
I can't see the files on my USB disk
I know there are about 250 million threads about airport USB disk problems, but I can't see one with my specific drama. I can connect, see the drive (its a LaCie 250GB) and move stuff to it via the airport. The problem is that I cant see the files on
-
i have Macbook Air. One day i am using email-Entrouage, sudden it stuck up. I stopped it and start entourage again but it start verify and and rebuild but not rebuilt. email are 41.5 GB and free 5 GB. When problem not resolved i also copied that emai