Problem with tableview iterator
Dear friends.
I try to adopt tableview iterator in my customer's BSP pages. So, I programmed test page.
METHOD if_htmlb_tableview_iterator~render_row_start .
m_row_ref ?= p_row_data_ref.
ENDMETHOD.
M_ROW_REF is "Static Attribute" and "Public" and "Type Ref To Z3TYDISP"
z3tydisp has structure as below
REQNO NUMC 12
VGUBUN CHAR 1
DSCOFVGUBUN STRING 0
REQDT DATS 8
RNAME CHAR 10
VCOMP CHAR 30
VNAME CHAR 10
VPLACE CHAR 5
VPLACEDSC CHAR 20
APPROVAL CHAR 1
DSCOFAPPROVAL STRING 0
AND... p_row_data_ref has structure below
REQNO N 12
VGUBUN C 1
DSCOFVGUBUN g 0
REQDT D 8
RNAME C 10
VCOMP C 30
VNAME C 10
VPLACE C 5
VPLACEDSC C 20
APPROVAL C 1
DSCOFAPPROVAL g 0
In my option, p_row_data_ref has same structure compared with z3tydisp. But there is "CX_SY_MOVE_CAST_ERROR". How I have to define "z3tydisp"????
>><b>M_ROW_REF is "Static Attribute" and "Public" and "Type Ref To Z3TYDISP"</b>
instead of this make your M_ROW_REF a instantaneous attribute. since static attribute are intantiated only once when object created and are shared by all other intances. m_row_ref contains data about the table you are going to render using tableview. so it should be public, so that get different data for different iterator objects.
your p_row_data_ref must be of type ref to data which is superior class of data types.
and if you have defined iterator "IF_HTMLB_TABLEVIEW_ITERATOR" in your interfaces. then you need not to define structure for p_row_data_ref, its already there in interface.
hope this will solve your problem,
regards,
hemendra
Similar Messages
-
Hi all, we're development a BSP that display a table with 2 fields, Mat. Number and visible, the "visible" field is a char1 type.
We want use htmlb:tableview to display this table, but the field visible must appear like a button without text. If we push that button, the value of field must be updated.
we want to know if the following code is correct:
<htmlb:tableView
id = "ofer"
headerText = "Ofert"
headerVisible = "true"
design = "alternating"
visibleRowCount = "5"
fillUpEmptyRows = "true"
table = "<I_exit>" >
<htmlb:tableViewColumns>
<htmlb:tableViewColumn
columnName = "EMATN"
width = "100"
title = "Cod. Mat." />
<htmlb:tableViewColumn
columnName = "VISIBLE"
width = "30"
<b>edit = "true"</b>
<b>type = "button"</b>
title = "Visible" />
</htmlb:tableViewColumns>
</htmlb:tableView>
we also think that is posible work with the iterator of the table. Oninitialitation event look for value of field and display an image. And handle the onclickevent, that will update the field if we push down.
what is the better way to do that?
Thanks.
Message was edited by: angel JuradoHi,
Please go through the weblog,
/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator
and the forum,
Re: Table View Update
Regards,
Azaz Ali. -
Strange Problem with tableView:didSelectRowAtIndexPath:
Hi,
I have a strange problem with selecting rows in a table view (iPhone OS 3.0):
I select a row in the table view and the method tableView:didSelectRowAtIndexPath: doesn't get called. After that I select another row in the same table view and the method gets called, but with the indexPath of the first selected row. When I select a third cell in the table the method tableView:didSelectRowAtIndexPath: gets called with the Index Path of the second selected row and so on
When I click on the same row for example n times in succession, tableView:didSelectRowAtIndexPath: doesn't get called, but when I select another row the method gets called n times with the index path of the first row.
I'm using different table views in my app and in only one of them I have this problem. Unfortunately I have no clue whats the cause for that behavior. (the problematic table view is created and used like the other ones).
I hope anybody has a hint for me.
Thanks,
ThomasHi,
since I didn't found a reason for the problem I recreated the ViewController class with the table view from scratch and the problem disappeared ... -
Problem with tableView SelectionMode = "MULTISELECT"
Hi,
I have a dropdownlistbox. In that I have different groups. If I select first group then entries related to that group are displayed in tableView which has selectionMode = "MULTISELECT". I select some rows in that. when I select another group then the selected rows in the first group are still selected in the second group. To be clear if I select rows 1 & 3 in first group. then going to second group, will also have 1 & 3 rows selected.
How to clear that..
Thanks in Advance..Hi Raju
There are two ways to do this....
if you have defined your table like this in Page layout
<htmlb:tableView id = "tv1" design = "STANDARD" width = "590" table = "<%= T_T800 %>" selectionMode = "MULTISELECT" selectedRowIndextable= "<%= selectedRowIndextable %>"selectedRowIndex= "<%= selectedRowIndex %>" onRowSelection = "selInprocess" footerVisible="false" fillUpEmptyRows = "FALSE" > <htmlb:tableViewColumns>
Then on InputProcessing...Just write this,.....
CLEAR SELECTEDROWINDEXTABLE.
APPEND INITIAL LINE TO SELECTEDROWINDEXTABLE.
SELECTEDROWINDEX = 0.
<b>Otherwise</b>
oninputprocessing you can call
cl_htmlb_manager=>check_tableview_all_rows(
rowcount = rowcount
request = request
id = <tableviewid>
check = ' '
KEYTABLE = KEYTABLE
to uncheck all rows.
chec = 'X' will select all rows.
Do Reward points if found helpful....
Cheers:)
Mithlesh -
Problem with iterator in tableview
Hi, Im having a problem with an iterator in a tableview. Sometime ago I use an iterator in a BSP with flow logic, I created the class fill the methods GET_COLUMN_DEFINITIONS and RENDER_CELL_START. And worked fine.
Now, Im working in another BSP and this time I wanted to use MVC, so I have been reading but cant figure it out what Im missing out.
In the controller of my page I add the Interface IF_HTMLB_TABLEVIEW_ITERATOR
I ridefine the methods GET_COLUMN_DEFINITIONS and RENDER_CELL_START (I think that you dont have to redifine GET_COLUMN_DEFINITIONS but did it anyway just in case).
This is my RENDER_CELL_START
IF NOT ( p_column_key = 'ICON' ).
RETURN.
ENDIF.
FIELD-SYMBOLS: <row> TYPE ANY, <col> TYPE ANY.
DATA: ti_results TYPE ZBSPREP_VEND_T,
wa_results TYPE ZBSPREP_VEND.
ASSIGN p_row_data_ref->* TO <row>.
ASSIGN COMPONENT p_column_key OF STRUCTURE <row> TO <col>.
wa_results = <col>.
DATA: html_bee TYPE REF TO CL_BSP_BEE_HTML.
CREATE OBJECT html_bee.
LOOP AT it_results INTO wa_results.
icon = CL_BSP_MIMES=>SAP_ICON( id = 'ICON_GREEN_LIGHT' ).
ENDLOOP.
p_replacement_bee = CL_HTMLB_IMAGE=>FACTORY( id = p_cell_id src = icon ).
In my table view the column ICON doesnt show anything and the rare part is if I put breakpoint in the method and execute the page doesnt stop.
So I dont know if Im missing something.
My tableview layout is this:
<htmlb:tableView id = "Monitor"
selectionMode = "SINGLESELECT"
onRowSelection = "rowSelection"
table = "<%= it_results %>"
iterator = "<%= iterator %>"
design = "ALTERNATING"
filter = "SERVER"
sort = "SERVER"
headerVisible = "FALSE"
footerVisible = "FALSE">
I declare a attribute iterator TYPE IF_HTMLB_TABLEVIEW_ITERATOR.
Someone could give a hand ?Solved, I forget to set the attribute of the view in the REQUEST Method.
result_view->set_attribute( name = 'iterator' value = me ). -
Hello.
I have some problems with Iterator when I try to loop through a Collection.
for (Iterator i=arrFinallArray.iterator();i.hasNext();)
objtable.insertRow(objtable.getRowCount(), new Object[] { arrFinallArray.iterator().next().getID(),
arrFinallArray.iterator().next().getFirstNumber(),
arrFinallArray.iterator().next().getSecondNumber(),
arrFinallArray.iterator().next().getThirdNumber(),
arrFinallArray.iterator().next().getMA(), arrFinallArray.iterator().next().getMG() });
i.next();
}The results are stored in a Jtable object. The strange fact is that this code returned just first object from Collection.He is returned for each time when I iterate through Collection
What's going on ?
Many Thanks
Julian ACalling iterator() gives you a new iterator. Calling next() on that will give you the first item.
So if you call iterator().next() multiple times you will get the first item multiple times.
You need to call next() on the reference to the original iterator, not create lots of new iterators.
Better yet, when you want to iterate over all the contents of a collection use "enhanced for":
for( final Object obj : collection ) {
} -
Synchronisation problem with deleting an appointment from an iterating appointment
Hello,
I have a problem with the synchronisation of appointments from iCal (Mac OS X 10.7.3) to my iPhone 3GS (iOS 5.1) with iTunes (10.6.1 (7)).
Scenario:
I create an iterating appointment (e.g. each week) in iCal. Than I synchronise these appointments with my iPhone. After that I delete one specific appointment (not the whole iterating appointments) in iCal and synchronise the calendar via iTunes again.
Now the appointment I deleted in iCal still exists on my iPhone. If I choose the option "replace all appointments on my iPhone" in iTunes it doesn't work and the deleted appointment still exists in my iPhone calendar.
Any solutions for this problem? Or is it a known bug?Hi,
try to make the request status into red in monitor and then delete. if the request deletion taking long time try to change the QM status in to green. i think then the delete box will dissaper. again start from begin convert the status to RED in monitor for that particular request. and then delete it. -
[JS CS3] Problem with iterating xml tags
Hello,
Below is a script that is supposed to find text in a document and then tag it with an xml tag. I have run into a problem, which if I solve in the way I know how, causes another problem.
When I iterate in a positive direction--i++--the first instance of the text (in this example "abc") is correctly tagged. But the second instance the tag recedes by two characters, that is, tags the three characters prior to the "c." A third instance will recede two more characters, ad nauseam, if my Latin is correct.
The solution is to iterate backwards, i.e., i--. But this causes another problem. If there is more than one story, then the xml structure reverses the order of the stories. The elements within a story are ordered correctly however.
So why is this happening and how can I solve it?
Thanks,
Tom
var myDoc = app.activeDocument;
var findABC = theTextFinder(myDoc,"abc");
xmlTagIt(myDoc,"abc",UIColors.RED,findABC);
//*****functions*******
function xmlTagIt(docRef, tagName,colorOfTag, arrToTag){
var tagName, colorOfTag, arrToTag;
myDoc.xmlViewPreferences.showStructure = true;
myDoc.xmlViewPreferences.showTaggedFrames =true;
myDoc.xmlViewPreferences.showTagMarkers = true;
myDoc.xmlViewPreferences.showTextSnippets =false;
myDoc.xmlPreferences.defaultStoryTagColor = UIColors.WHITE;
var rootElement = myDoc.xmlElements.item(0);
if (myDoc.xmlTags.item(tagName) == null) {
var tagRef = myDoc.xmlTags.add(tagName, colorOfTag);
} else {//if tag already exists then stop the script. Avoid double tagging
myDoc.xmlViewPreferences.showStructure = true;
alert("You have already run this script.");
exit();
}//end else
//for (var i = arrToTag.length-1; 0 <= i; i--){
for (var i = 0; i <= arrToTag.length-1; i++){
var elementRef = rootElement.xmlElements.add (tagRef,arrToTag[i]);
}//end for i
}//end function xmlTagIt
function theTextFinder(docRef,textFindIt){//last argument is the string of text to find
app.findTextPreferences = NothingEnum.NOTHING;
app.changeTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.findWhat = textFindIt;
var arrTextFindIt = myDoc.findText();
return arrTextFindIt;
}//end theTextFinderDave,
Thanks for the reply.
I'm not sure what you mean by "convert the references on the fly." You mean find a way to advance two characters forward and tag that? In the script I submitted here I am only searching for "abc," which of course I would not search or at all in real life. The script uses grep to search for about twenty different typographical errors that typically appear and tags them all.
Reiterating backwards seems, at first sight the way to go. But I haven't a clue as to how to reverse the order of the stories. I can get an array of stories, and array.reverse() them, but am not sure how to then make the script put this reversed order into the xml structure. Any hints?
There, of course is bigger problem with the stories. If the document is written with one story created after another then the order of them is top to botom. But if say a text frame edited into the middle of all this, that story is still the last one in the xml structure. At least in one test, that was so. Maybe the way to solve this is to build an array of stories that have as one xml attribute the page it first appears on. Then order the array according to that attribute.
Any advice you give will be appreciated.
Thanks,
Tom -
Composite Element in Tableview Iterator
I want to use a <phtmlb:matrix> element in a tableview iterator to arrange the content of a cell.
I tried to follow Brians Weblog on composite elements.
In my test example, I just want to combine two fields of t000 into one cell. Of course I know, that concatenation would be more easy here, but that would not answer my questions.
Thought it could look like this:
METHOD render_cell_start.
DATA:
l_o_matrix TYPE REF TO cl_phtmlb_matrix,
l_o_bsp_element TYPE REF TO cl_bsp_element,
l_string TYPE STRING.
CASE p_tableview_id.
WHEN 'TABLE_T000'.
l_o_matrix = cl_phtmlb_matrix=>factory( ).
WHILE o_page_context->element_process( element = l_o_matrix )
= cl_bsp_element=>co_element_continue.
Cell 1
CLEAR: l_o_matrix->mc_backgrounddesign,
l_o_matrix->mc_design,
l_o_matrix->mc_separation.
l_o_matrix->do_set_data( element_name = 'matrixCell' ).
l_string = me->t000-mandt.
l_o_bsp_element = cl_htmlb_textview=>factory( text = l_string ).
WHILE o_page_context->element_process( element = l_o_bsp_element )
= cl_bsp_element=>co_element_continue.
ENDWHILE.
Cell 2
CLEAR: l_o_matrix->mc_backgrounddesign,
l_o_matrix->mc_design,
l_o_matrix->mc_separation.
l_o_matrix->mc_halign = 'LEFT'.
l_o_matrix->mc_valign = 'TOP'.
l_o_matrix->do_set_data( element_name = 'matrixCell' ).
l_string = me->t000-mtext.
l_o_bsp_element = cl_htmlb_textview=>factory( text = l_string ).
WHILE o_page_context->element_process( element = l_o_bsp_element )
= cl_bsp_element=>co_element_continue.
ENDWHILE.
ENDWHILE.
p_replacement_bee = l_o_matrix.
ENDCASE.
ENDMETHOD.
However, that does not work.
First, the list of T000-MANDT fields is rendered twice:
into the tableview and into a list before the tableview.
Second: T000-MTEXT does not show up at all.
What do I do wrong?
I feel that I do not completely understand how the rendering is processed.
Thanks for our help.
JuergenThe following is the example from Brian's weblog, updated for design2003. It doesn't use the Matrix however. Perhaps it will help.
It still doesn't render quite like it did under design2002. I'm not sure if there is a good way to combine multiple input fields into one cell any longer. I know others have had a problem with this as well. I will have to look closer at your matrix attempt.
when 'SEATS'.
if p_edit_mode is initial.
data: max type string, occ type string,
value type string.
max = m_row_ref->seatsmax + m_row_ref->seatsmax_b
+ m_row_ref->seatsmax_f.
occ = m_row_ref->seatsocc + m_row_ref->seatsocc_b
+ m_row_ref->seatsocc_f.
condense: max, occ.
concatenate occ ` / ` max into value.
p_replacement_bee = cl_htmlb_textview=>factory(
text = value ).
else.
data: icon_plane2 type string.
icon_plane2 = cl_bsp_mimes=>sap_icon(
id = 'ICON_WS_PLANE' ).
data: image type ref to cl_htmlb_image.
image = cl_htmlb_image=>factory(
id = p_cell_id
src = icon_plane2 ).
data: if_first type ref to cl_htmlb_inputfield.
if_first = cl_htmlb_inputfield=>factory( id = p_cell_id
id_postfix = '_first'
type = 'INTEGER' size = '4' ).
if_first->value = m_row_ref->seatsocc_f.
data: if_bus type ref to cl_htmlb_inputfield.
if_bus = cl_htmlb_inputfield=>factory( id = p_cell_id
id_postfix = '_bus'
type = 'INTEGER' size = '4' ).
if_bus->value = m_row_ref->seatsocc_b.
data: if_econ type ref to cl_htmlb_inputfield.
if_econ = cl_htmlb_inputfield=>factory( id = p_cell_id
id_postfix = '_econ'
type = 'INTEGER' size = '4' ).
if_econ->value = m_row_ref->seatsocc.
data: tag_gl type ref to cl_htmlb_gridlayout,
tag_glc_if1 type ref to cl_htmlb_gridlayoutcell,
tag_glc_if2 type ref to cl_htmlb_gridlayoutcell,
tag_glc_if3 type ref to cl_htmlb_gridlayoutcell.
tag_gl = cl_htmlb_gridlayout=>factory(
columnsize = '3' rowsize = '1' ).
tag_glc_if1 = cl_htmlb_gridlayoutcell=>factory(
columnindex = '1' rowindex = '1' ).
tag_glc_if2 = cl_htmlb_gridlayoutcell=>factory(
columnindex = '2' rowindex = '1' ).
tag_glc_if3 = cl_htmlb_gridlayoutcell=>factory(
columnindex = '3' rowindex = '1' ).
data: seats_bee type ref to cl_bsp_bee_table.
create object seats_bee.
seats_bee->add( level = 1 element = tag_gl ).
seats_bee->add( level = 2 element = tag_glc_if1 ).
seats_bee->add( level = 3 element = if_first ).
seats_bee->add( level = 2 element = tag_glc_if2 ).
seats_bee->add( level = 3 element = if_bus ).
seats_bee->add( level = 2 element = tag_glc_if3 ).
seats_bee->add( level = 3 element = if_econ ).
p_replacement_bee = seats_bee.
endif.
Message was edited by: Thomas Jung -
Problem with setting oracle type parameter in viewobject query
Hi There,
I am facing a problem with JDev1013. I have a view that has JDBC positional parameters that are supposed to be in parameters for function like:
SELECT x.day, x.special_exact_period_only
FROM (
SELECT x.day, x.special_exact_period_only
FROM (
SELECT
x.day,
rb.special_exact_period_only
FROM TABLE (
RentabilityPkg.findMarkerSlots(
'start',
? /* dchannel */,
NULL,
? /* resorts */,
'special',
NULL,
? /* code */,
NULL,
TRUNC(SYSDATE),
TRUNC(SYSDATE + 365 * 2),
NULL
) x
JOIN resourcebase rb USING (rentabilitymanager_id)
UNION
SELECT
x.day,
rb.special_exact_period_only
FROM TABLE (
RentabilityPkg.findMarkerSlots(
'start',
? /* dchannel */,
NULL,
? /* resorts */,
'composition',
NULL,
? /* code */,
NULL,
TRUNC(SYSDATE),
TRUNC(SYSDATE + 365 * 2),
NULL
) x
JOIN resourcebase rb USING (rentabilitymanager_id)
)x
ORDER BY x.day
) x
WHERE ROWNUM <= 30now the JDBC positional parameters take our custom defined list type defined as:
CREATE TYPE NumberList AS TABLE OF NUMBER;
we are setting the parameter in the views with the help of oracle.sql.ARRAY class like:
* Set parameters.
public void setParams(Integer dchannelId, Integer[] resorts, String specialCode)
try {
System.out.println(this.getClass() + ".setParams()");
ARRAY arrParam1 = ((NWSApplicationModule)getApplicationModule()).toSQLNumberList(Arrays.asList(resorts));
ARRAY arrParam2 = ((NWSApplicationModule)getApplicationModule()).toSQLNumberList(Arrays.asList(resorts));
System.out.println("arrParam1 - " + arrParam1);
System.out.println("arrParam1 - " + arrParam1);
System.out.println(this.getClass() + " ARRAY - " + arrParam1.getArray());
System.out.println(this.getClass() + " -- " + arrParam1.length());
System.out.println("arrParam2 - " + arrParam2);
System.out.println("arrParam2 - " + arrParam2);
System.out.println(this.getClass() + " ARRAY - " + arrParam2.getArray());
System.out.println(this.getClass() + " -- " + arrParam2.length());
Object[] params =
{ dchannelId,
arrParam1,
specialCode,
dchannelId,
arrParam2,
specialCode
setWhereClauseParams(params);
System.out.println("DONE WITH " + this.getClass() + ".setParams()");
catch(Exception ex)
ex.printStackTrace(System.out);
}the toSQLNumberList() method is defined in our App module baseclass as follows:
public ARRAY toSQLNumberList(Collection coll)
debug("toSQLNumberList()");
DBTransaction txn = (DBTransaction)getTransaction();
debug("txn - " + txn + " : " + txn.getClass());
return NWSUtil.toSQLNumberList(coll, getConnection(txn));
public static ARRAY toSQLNumberList(Collection c, Connection connection)
//printTrace();
debug("toSQLNumberList()");
try
ArrayDescriptor numberList = ArrayDescriptor.createDescriptor("NUMBERLIST", connection);
NUMBER[] elements = new NUMBER[c == null ? 0 : c.size()];
if (elements.length > 0 )
Iterator iter = c.iterator();
for (int i = 0; iter.hasNext(); i++)
elements[i] = new NUMBER(iter.next().toString());
return new ARRAY(numberList, connection, elements);
catch (Exception ex)
ex.printStackTrace();
return null;
protected Connection getConnection(DBTransaction dbTransaction)
//return null;
debug("Inside getConnection()");
CallableStatement s = null;
try
* Getting Conenction in BC4J is dirty but its better
* as otherwise we might end up coding with connections
* and the Transaction Integrety will be
s = dbTransaction.createCallableStatement("BEGIN NULL; END;", 0);
debug("DOING s.getConnection()...");
Connection conn = s.getConnection();
debug("DONE WITH s.getConnection()...");
/*try
throw new Exception("TEST");
catch (Exception ex)
ex.printStackTrace(System.out);
debug("conn CLASS - " + conn.getClass());
return conn;
catch (Exception ex)
ex.printStackTrace();
return null;
finally
try { s.close(); }
catch (Exception ex) {}
}Whenever we try setting the parameters in view using setParams() and use this view to set the model of a java control it thorws the following exception :
[2006-10-10 12:34:48,797 AWT-EventQueue-0 ERROR] JBO-28302: Piggyback write error
oracle.jbo.PiggybackException: JBO-28302: Piggyback write error
at oracle.jbo.common.PiggybackOutput.getPiggybackStream(PiggybackOutput.java:185)
at oracle.jbo.common.JboServiceMessage.marshalRefs(JboServiceMessage.java:267)
at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:343)
at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:316)
at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.processMessage(AbstractRemoteApplicationModuleImpl.java:2283)
at oracle.jbo.server.ApplicationModuleImpl.doMessage(ApplicationModuleImpl.java:7509)
at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.sync(AbstractRemoteApplicationModuleImpl.java:2221)
at oracle.jbo.server.remote.ejb.ServerApplicationModuleImpl.doMessage(ServerApplicationModuleImpl.java:79)
at oracle.jbo.server.ejb.SessionBeanImpl.doMessage(SessionBeanImpl.java:474)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.interceptor.system.TxBeanManagedInterceptor.invoke(TxBeanManagedInterceptor.java:53)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.StatefulSessionEJBObject.OC4J_invokeMethod(StatefulSessionEJBObject.java:840)
at RemoteAMReservation_StatefulSessionBeanWrapper906.doMessage(RemoteAMReservation_StatefulSessionBeanWrapper906.java:286)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
## Detail 0 ##
java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
at oracle.jbo.common.SvcMsgResponseValues.writeObject(SvcMsgResponseValues.java:116)
at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
at oracle.jbo.common.PiggybackOutput.getPiggybackStream(PiggybackOutput.java:173)
at oracle.jbo.common.JboServiceMessage.marshalRefs(JboServiceMessage.java:267)
at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:343)
at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:316)
at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.processMessage(AbstractRemoteApplicationModuleImpl.java:2283)
at oracle.jbo.server.ApplicationModuleImpl.doMessage(ApplicationModuleImpl.java:7509)
at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.sync(AbstractRemoteApplicationModuleImpl.java:2221)
at oracle.jbo.server.remote.ejb.ServerApplicationModuleImpl.doMessage(ServerApplicationModuleImpl.java:79)
at oracle.jbo.server.ejb.SessionBeanImpl.doMessage(SessionBeanImpl.java:474)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.interceptor.system.TxBeanManagedInterceptor.invoke(TxBeanManagedInterceptor.java:53)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
at com.evermind.server.ejb.StatefulSessionEJBObject.OC4J_invokeMethod(StatefulSessionEJBObject.java:840)
at RemoteAMReservation_StatefulSessionBeanWrapper906.doMessage(RemoteAMReservation_StatefulSessionBeanWrapper906.java:286)
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)This is a typical interaction between 2 server-side components (view-object and app module). Now the question is why is this exception thrown? Any answers?
This application is one that we have migrated from 904 to 1013 and are trying to get it running in 3-tier.
Regards,
AnupamSorry I missed out some semicolons, the script follws:
-- The following TABLE was created to simulate the issue
CREATE TABLE TEST_OBJECT
ASSET_ID NUMBER,
OBJECT_ID NUMBER,
NAME VARCHAR2(50)
INSERT INTO TEST_OBJECT VALUES(1,1,'AAA');
INSERT INTO TEST_OBJECT VALUES(2,2,'BBB');
INSERT INTO TEST_OBJECT VALUES(3,3,'CCC');
COMMIT;
SELECT * FROM TEST_OBJECT;
-- The following TYPES was created to simulate the issue
CREATE OR REPLACE
TYPE DUTYRESULTOBJECTTAB AS TABLE OF DUTYRESULTOBJECT;
CREATE OR REPLACE
type DutyResultObject as object
( ASSET_ID number,
OBJECT_ID number,
NAME varchar2(150)
-- The following PACKAGE N FUNCTION was created to simulate the issue
CREATE OR REPLACE PACKAGE TESTOBJECTPKG
IS
FUNCTION OBJECTSEARCH(P_RESOURCE IN NUMBERLIST) RETURN DUTYRESULTOBJECTTAB;
END;
CREATE OR REPLACE PACKAGE BODY TESTOBJECTPKG
IS
FUNCTION OBJECTSEARCH(P_RESOURCE IN NUMBERLIST) RETURN DUTYRESULTOBJECTTAB
IS
BULKDUTYRESULTOBJECTTAB DUTYRESULTOBJECTTAB;
BEGIN
SELECT DUTYRESULTOBJECT(ASSET_ID, OBJECT_ID, NAME)
BULK COLLECT INTO BULKDUTYRESULTOBJECTTAB
FROM TEST_OBJECT;
RETURN BULKDUTYRESULTOBJECTTAB;
END;
END;
[\code] -
Problem with rotation and landscape mode in iOS 8
From start of iOS 8 I have got problem with rotation in my iPhone 5S 32GB as well as in my iPad mini retina 32GB. Automatical rotation to landscape mode is not working correctly. For example if you take the phone or tablet to landscape mode in base display and tap to Safari, Mail, Messages, the app will start but stay in normal mode, not landscape. Then you have to back the phone to normal portrait mode and back to landscape and only then the phone do the landscape mode. I have never seen this problem in iOS 7 or older.
Could you help me anyone with this problem? Or is the problem generally in iOS 8.
Thanks a lot
JakubBrian, thanks, but it's not a rotation lock issue - at least not relating to the rotation lock setting. It's just a general use setting. Right now i have my iPhone propped in landscape mode. If I now hit the home button, essentially returning to a portrait setting though my phone is still positioned in landscape, then open any other app that supports landscape, that app WILL NOT orient itself to landscape mode. It will stay in portrait mode. The phone has to be physically oriented to portrait, then back to landscape for the app to register landscape mode properly. This is a glitch, and not a rotation lock issue. it ought to be noted that this was not an issue in iOS 7 or any previous iteration.
-
Problems with the Proxy Programme--Please help
Hi All,
I have written a simple proxy server in the form of a servlet. I changed the proxy config of my browser to connect to this servlet hosted on the default context(http://localhost:8080) of the Tomcat 5.0.25 . Well , this servlet internally connects to the proxy of the corporate LAN . The logic that I have applied is as follows. The servlet gets the request from the client (ie the browser in this case) , extracts the headers and contents from the request, sets them to a new request that it forms and finally send this new request to the proxy. When the proxy responds, the servlet collects the response headers and contents adn writes them in its response. To sum up , this servlet transparently carries the requests and responses between the client(browser) and the corporate LAN proxy. Now the problem is this. Let's say , now I am accessing http://www.google.com.The browser sends a request to my servlet with the following headers as they are extracted by my servlet.
ProxyServer:::>posting request
ProxyServer:::>headerValue::> headerName = accept : headerValue=*/*
ProxyServer:::>headerValue::> headerName = referer : headerValue=http://www.google.com/
ProxyServer:::>headerValue::> headerName = accept-language : headerValue=en-us
ProxyServer:::>headerValue::> headerName = proxy-connection : headerValue=Keep-Alive
ProxyServer:::>headerValue::> headerName = user-agent : headerValue=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; UB1.4_IE6.0_SP1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
ProxyServer:::>headerValue::> headerName = host : headerValue=www.google.com
ProxyServer:::>headerValue::> headerName = cookie : headerValue=PREF=ID=1be27c0a74f198ca:TM=1082058853:LM=1082058853:S=bu6ORrygzm8AUkm8
ProxyServer:::>postRequest
I set these headers into a new connection opened to the proxy and post a fresh request to the proxy,which, in turn responds with the following headers.
ProxyServer:::>posted request successfully
ProxyServer:::>writing response
ProxyServer:::>writeResponse-->headerName = Proxy-Connection : headerValue = [close]
ProxyServer:::>writeResponse-->headerName = Content-Length : headerValue = [257]
ProxyServer:::>writeResponse-->headerName = Date : headerValue = [Tue, 13 Jul 2004 14:01:40 GMT]
ProxyServer:::>writeResponse-->headerName = Content-Type : headerValue = [text/html]
ProxyServer:::>writeResponse-->headerName = Server : headerValue = [NetCache appliance (NetApp/5.5R2)]
ProxyServer:::>writeResponse-->headerName = Proxy-Authenticate : headerValue = [Basic realm="Charlotte - napxyclt2"]
ProxyServer:::>writeResponse-->headerName = null : headerValue = [HTTP/1.1 407 Proxy Authentication Required]
ProxyServer:::>writeResponse exiting
ProxyServer:::>wrote response successfully
I write these headers back to the client. According to what I was thinking, the client ie the browser would open a new dialog box asking for username/password owing to the presence of the "Proxy-Authenticate " header. But it does not happen that way. Rather the browser stops responsding and displays a blank page. Does anyone know why it happens this way? I am pasting the server prog below for everybody's reference.
package server.proxy;
//import all servlet related classes
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
import java.net.*;
import server.resources.*;
//My Proxy server --->Currently it is very simplea and relies on
//other proxy servers of an already connected network.
public class ProxyServer extends HttpServlet
//stores the resource bundle
private ServerResBundle resBundle = null;
//checks for the mode of operation
private boolean proxySet = false;
private String proxy = null;
//storing the original System out/err etc
private PrintStream sysOutOrig = null;
private PrintStream sysErrOrig = null;
private InputStream sysInOrig = null;
//initialise certain features that are required later
public void init() throws ServletException
try
//initialise the resource bundle
this.initResBundle();
System.out.println("ProxyServer:::>res bundle init");
//set the mode of operation
this.setMode();
System.out.println("ProxyServer:::>mode set");
//set the system out and err --System.setOut etc
this.setSystemOutErr();
System.out.println("ProxyServer:::>in/out/err set");
}//End try
catch(Exception e)
System.out.println("Exception in init..."+(e.getMessage()));
throw new ServletException(e);
}//Edn
catch(Throwable e)
System.out.println("Irrecoverable Error...");
throw new ServletException(e);
}//End
}//End init
//method to init the resource bundle;
private void initResBundle()
this.resBundle = ServerResBundle.getBundle();
}//End
//method to set the mode of the server--proxy or direct
private void setMode()
//read the target proxy property from the bundle and
//if it is set,take that URL
String temp = (String)(this.resBundle.getResource(ResKeys.PROXY_SERVER));
if ( (temp != null) && (temp.length() > 0) )
this.proxySet = true;
this.proxy = temp;
temp = null;
}//End
}//End
//method to set the system out and err etc
private void setSystemOutErr() throws Exception
//keep a copy of the original system out and error
this.sysOutOrig = System.out;
this.sysErrOrig = System.err;
try
//read the options adn if they are set, take the values directly
String newOutStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_OUT));
String newErrStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_ERR));
if ((newOutStr != null) && (newOutStr.length() > 0))
System.setOut(new PrintStream(new FileOutputStream(new File(newOutStr),true),true));
}//End if
if ((newErrStr != null) && (newErrStr.length() > 0))
System.setErr(new PrintStream(new FileOutputStream(new File(newErrStr),true),true));
}//End if
}//End
catch(Exception e)
//restore the stuff
System.setOut(this.sysOutOrig);
System.setErr(this.sysErrOrig);
}//End
}//End
//this is where the proxy functionalities will be embedded
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,java.io.IOException
//conenction URL
URL target = null;
//conenction to the remote object
URLConnection targetConn = null;
//stores the OOS and the OIS
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try
//check for the mode of operation
if (proxySet)
URLConnection objects go through two phases: first they are created, then they are connected.
After being created, and before being connected, various options can be specified
(e.g., doInput and UseCaches). After connecting, it is an error to try to set them.
Operations that depend on being connected, like getContentLength, will implicitly perform the connection,
if necessary.
//for the URL to the proxy
target=new URL(this.proxy);
//conenct to the proxy
targetConn = target.openConnection();
//set the details of the connectuon
targetConn.setDoInput(true);
targetConn.setDoOutput(true);
targetConn.setUseCaches(false);
// If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog. If false, then no user interaction is allowed
targetConn.setAllowUserInteraction(true);
//connect to the remote object
// targetConn.connect();//call this only when all the request properties are set
System.out.println("ProxyServer:::>posting request");
//post the received request to the URL
this.postRequest(targetConn,req);
System.out.println("ProxyServer:::>posted request successfully");
System.out.println("ProxyServer:::>writing response");
//receive the response
//write the received response to the client
this.writeResponse(targetConn,resp);
System.out.println("ProxyServer:::>wrote response successfully");
}//End if
else
//currently this functionality is not supported
throw new ServletException(
(String)(this.resBundle.getResource(ResKeys.ERR_FUNC_NOTSUPPORTED)));
}//End
}//End try
catch(Exception e)
if(e instanceof ServletException)
throw (ServletException)e;
}//End
if (e instanceof IOException)
throw (IOException)e;
}//End
//wrap it up in ServletException
throw new ServletException(e);
}//End
}//End
//method to write the response back to the client
private void writeResponse(URLConnection targetConn,HttpServletResponse resp)
throws ServletException
//get all the header fields from the response connection and set them to the
//response of the servlet
Map headerFields = null;
Iterator headerFieldEntries = null;
Map.Entry header = null;
//stores the input stream to the conn
BufferedReader brConn = null;
//stores the writer to the response
PrintWriter prResp = null;
//checks if the proxy authentication needed or not
boolean proxyAuthReqd = false;
try
//juste ensuring that the proxy authentication is reset
proxyAuthReqd = false;
if( (targetConn != null) && (resp != null) )
//Returns an unmodifiable Map of the header fields.
//The Map keys are Strings that represent the response-header field names.
//Each Map value is an unmodifiable List of Strings that represents the corresponding
//field values
headerFields = targetConn.getHeaderFields();
//Returns a set view of the mappings contained in this map
Set temp = headerFields.entrySet();
//Returns an iterator over the elements in this set
headerFieldEntries = temp.iterator();
if (headerFieldEntries != null)
while (headerFieldEntries.hasNext())
Object tempHeader = headerFieldEntries.next();
if (tempHeader instanceof Map.Entry)
header = (Map.Entry)tempHeader;
Object headerName = header.getKey();
Object headerValue=header.getValue();
System.out.println("ProxyServer:::>writeResponse-->headerName = "+headerName+" : headerValue = "+headerValue);
//do not select the key-value pair if both the key adn the value are null
if ( ( headerName == null) && (headerValue == null) )
continue;
}//Enmd
if (headerValue != null)
List headerValList = null;
if (headerValue instanceof List)
headerValList = (List)headerValue;
}//End
if(headerValList != null)
for (int i=0;i<headerValList.size();i++)
Object headerValueStr = headerValList.get(i);
if (headerValueStr instanceof String)
//note that the header-key can not be null for addHeader
//I have made this temporary provision to make the programme work.
resp.addHeader(( (headerName==null)? ("null_header"+i) :(String)headerName),
(String)headerValueStr);
//check if the proxy authentication required or not
if (((String)headerValueStr).
indexOf(resp.SC_PROXY_AUTHENTICATION_REQUIRED+"") != -1)
System.out.println("ProxyServer:::>writeResponse-->proxy auth needed");
//proxy authentication is needed
proxyAuthReqd = true;
}//End
}//Ednd of
else if (headerValueStr == null)
resp.addHeader(( (headerName==null)? null :(String)headerName),
null);
}//End
}//End for
}//End if
}//End if
}//End
}//End while
}//End if
//get the writer to the client
prResp = resp.getWriter();
System.out.println("ProxyServer:::>writeResponse-->proxyAuthReqd="+proxyAuthReqd);
//juste test a simple header
System.out.println("Proxy-Authenticate = "+(resp.containsHeader("Proxy-Authenticate")));
//if the proxy asks you for authentication,pass on the same to the client
//from whom you have received the request.When this flag is true,the connection
//is closed by the remotehost adn hence any attempt to open in input steram
//results in an error ie IOException
if (!proxyAuthReqd)
//now get the content adn write it to the response too
brConn = new BufferedReader(new InputStreamReader(
targetConn.getInputStream()));
String tempStr = null;
while ((tempStr = brConn.readLine())!=null)
prResp.println(tempStr);
}//End while
//close the connections
brConn.close();
}//End if
else
prResp.println("Proxy Authentication needed...");
}//End
//close the streams
prResp.flush();
prResp.close();
}//End if
System.out.println("ProxyServer:::>writeResponse exiting\n");
}//End try
catch(Exception e)
throw new ServletException(e);
}//End
}//End
//method to post request to the internet
private void postRequest(URLConnection targetConn,HttpServletRequest req)
throws ServletException
//extract the header parameters and the body content from the incoming request
//and set them to the new connection
Enumeration reqHeaders = null;
//reads the incoming request's content
BufferedReader brReqRd = null;
PrintWriter prResWt = null;
//stores temp header names and values
String headerName = null;
String headerValue = null;
try
if( (targetConn != null) && (req != null) )
reqHeaders = req.getHeaderNames();
//extract a header adn set it to the new connection
while (reqHeaders.hasMoreElements())
headerName = (String)(reqHeaders.nextElement());
headerValue = req.getHeader(headerName);
targetConn.setRequestProperty(headerName,headerValue);
System.out.println("ProxyServer:::>headerValue::> headerName = "+headerName+" : headerValue="+headerValue);
}//End
System.out.println("ProxyServer:::>postRequest\n");
//establis the actual connection
//calling this method bfore the above loop results in IllegalStateException
targetConn.connect();
//NOTE : try reading from and writing into OIS and OOS respectively
//now read the contents and write them to the connection
// brReqRd = req.getReader(); //this hangs for some reason
brReqRd = new BufferedReader(new InputStreamReader(req.getInputStream()));
System.out.println("Got the reader..brReqRd = "+brReqRd);
if (brReqRd != null)
String temp = null;
//establish the printwriter
// prResWt = new PrintWriter(targetConn.getOutputStream(),true);
prResWt = new PrintWriter(targetConn.getOutputStream());
System.out.println("trying to read in a loop from brReqRd.. ready="+(brReqRd.ready()));
while( (brReqRd.ready()) && ((temp=brReqRd.readLine()) != null) )
System.out.println("In while::>temp = "+temp);
prResWt.println(temp);
}//Emd while
//close the streams adn go back
brReqRd.close();
prResWt.flush();
prResWt.close();
}//End
}//End outer if
System.out.println("ProxyServer:::>postRequest exiting\n");
}//End try
catch(Exception e)
throw new ServletException(e);
}//End
}//End
}//EndHi serlank ,
Thanks for your reply. Well , I initially I thought of not pasting the code,as it was too long. But I could not help it,as I thought I must show in code what I exactly meant. That's why I followed a description of my problem with the code. You could probably have copied the code and pasted it in one of your favourite editors to take a look at it. Did you,by any chance, try to read it on the browser? And as regards reposting the same message, I can say that I did it as I felt the subject was not quite appropriate in the first posting and I was not sure as to how I could delete/alter the posting. I am not asking for a code-fix,but some suggestions from some one who might ever have come across such a thing.Anyway, lemme know if you have any idea on it. Thanks... -
Performance problems with jdk 1.5 on Linux plattform
Performance problems with jdk 1.5 on Linux plattform
(not tested on Windows, might be the same)
After refactoring using the new features from java 1.5 I lost
performance significantly:
public Vector<unit> units;
The new code:
for (unit u: units) u.accumulate();
runs more than 30% slower than the old code:
for (int i = 0; i < units.size(); i++) units.elementAt(i).accumulate();
I expected the opposite.
Is there any information available that helps?Here's the complete benchmark code I used:package test;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;
public class IterationPerformanceTest {
private int m_size;
public IterationPerformanceTest(int size) {
m_size = size;
public long getArrayForLoopDuration() {
Integer[] testArray = new Integer[m_size];
for (int item = 0; item < m_size; item++) {
testArray[item] = new Integer(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (int index = 0; index < m_size; index++) {
builder.append(testArray[index]);
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getArrayForEachDuration() {
Integer[] testArray = new Integer[m_size];
for (int item = 0; item < m_size; item++) {
testArray[item] = new Integer(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (Integer item : testArray) {
builder.append(item);
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getArrayListForLoopDuration() {
ArrayList<Integer> testList = new ArrayList<Integer>();
for (int item = 0; item < m_size; item++) {
testList.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (int index = 0; index < m_size; index++) {
builder.append(testList.get(index));
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getArrayListForEachDuration() {
ArrayList<Integer> testList = new ArrayList<Integer>();
for (int item = 0; item < m_size; item++) {
testList.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (Integer item : testList) {
builder.append(item);
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getArrayListIteratorDuration() {
ArrayList<Integer> testList = new ArrayList<Integer>();
for (int item = 0; item < m_size; item++) {
testList.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
Iterator<Integer> iterator = testList.iterator();
while(iterator.hasNext()) {
builder.append(iterator.next());
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getLinkedListForLoopDuration() {
LinkedList<Integer> testList = new LinkedList<Integer>();
for (int item = 0; item < m_size; item++) {
testList.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (int index = 0; index < m_size; index++) {
builder.append(testList.get(index));
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getLinkedListForEachDuration() {
LinkedList<Integer> testList = new LinkedList<Integer>();
for (int item = 0; item < m_size; item++) {
testList.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (Integer item : testList) {
builder.append(item);
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getLinkedListIteratorDuration() {
LinkedList<Integer> testList = new LinkedList<Integer>();
for (int item = 0; item < m_size; item++) {
testList.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
Iterator<Integer> iterator = testList.iterator();
while(iterator.hasNext()) {
builder.append(iterator.next());
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getVectorForLoopDuration() {
Vector<Integer> testVector = new Vector<Integer>();
for (int item = 0; item < m_size; item++) {
testVector.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (int index = 0; index < m_size; index++) {
builder.append(testVector.get(index));
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getVectorForEachDuration() {
Vector<Integer> testVector = new Vector<Integer>();
for (int item = 0; item < m_size; item++) {
testVector.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
for (Integer item : testVector) {
builder.append(item);
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
public long getVectorIteratorDuration() {
Vector<Integer> testVector = new Vector<Integer>();
for (int item = 0; item < m_size; item++) {
testVector.add(item);
StringBuilder builder = new StringBuilder();
long start = System.nanoTime();
Iterator<Integer> iterator = testVector.iterator();
while(iterator.hasNext()) {
builder.append(iterator.next());
long end = System.nanoTime();
System.out.println(builder.length());
return end - start;
* @param args
public static void main(String[] args) {
IterationPerformanceTest test = new IterationPerformanceTest(1000000);
System.out.println("\n\nRESULTS:");
long arrayForLoop = test.getArrayForLoopDuration();
long arrayForEach = test.getArrayForEachDuration();
long arrayListForLoop = test.getArrayListForLoopDuration();
long arrayListForEach = test.getArrayListForEachDuration();
long arrayListIterator = test.getArrayListIteratorDuration();
// long linkedListForLoop = test.getLinkedListForLoopDuration();
long linkedListForEach = test.getLinkedListForEachDuration();
long linkedListIterator = test.getLinkedListIteratorDuration();
long vectorForLoop = test.getVectorForLoopDuration();
long vectorForEach = test.getVectorForEachDuration();
long vectorIterator = test.getVectorIteratorDuration();
System.out.println("Array for-loop: " + getPercentage(arrayForLoop, arrayForLoop) + "% ("+getDuration(arrayForLoop)+" sec)");
System.out.println("Array for-each: " + getPercentage(arrayForLoop, arrayForEach) + "% ("+getDuration(arrayForEach)+" sec)");
System.out.println("ArrayList for-loop: " + getPercentage(arrayForLoop, arrayListForLoop) + "% ("+getDuration(arrayListForLoop)+" sec)");
System.out.println("ArrayList for-each: " + getPercentage(arrayForLoop, arrayListForEach) + "% ("+getDuration(arrayListForEach)+" sec)");
System.out.println("ArrayList iterator: " + getPercentage(arrayForLoop, arrayListIterator) + "% ("+getDuration(arrayListIterator)+" sec)");
// System.out.println("LinkedList for-loop: " + getPercentage(arrayForLoop, linkedListForLoop) + "% ("+getDuration(linkedListForLoop)+" sec)");
System.out.println("LinkedList for-each: " + getPercentage(arrayForLoop, linkedListForEach) + "% ("+getDuration(linkedListForEach)+" sec)");
System.out.println("LinkedList iterator: " + getPercentage(arrayForLoop, linkedListIterator) + "% ("+getDuration(linkedListIterator)+" sec)");
System.out.println("Vector for-loop: " + getPercentage(arrayForLoop, vectorForLoop) + "% ("+getDuration(vectorForLoop)+" sec)");
System.out.println("Vector for-each: " + getPercentage(arrayForLoop, vectorForEach) + "% ("+getDuration(vectorForEach)+" sec)");
System.out.println("Vector iterator: " + getPercentage(arrayForLoop, vectorIterator) + "% ("+getDuration(vectorIterator)+" sec)");
private static NumberFormat percentageFormat = NumberFormat.getInstance();
static {
percentageFormat.setMinimumIntegerDigits(3);
percentageFormat.setMaximumIntegerDigits(3);
percentageFormat.setMinimumFractionDigits(2);
percentageFormat.setMaximumFractionDigits(2);
private static String getPercentage(long base, long value) {
double result = (double) value / (double) base;
return percentageFormat.format(result * 100.0);
private static NumberFormat durationFormat = NumberFormat.getInstance();
static {
durationFormat.setMinimumIntegerDigits(1);
durationFormat.setMaximumIntegerDigits(1);
durationFormat.setMinimumFractionDigits(4);
durationFormat.setMaximumFractionDigits(4);
private static String getDuration(long nanos) {
double result = (double)nanos / (double)1000000000;
return durationFormat.format(result);
} -
Performance problems with new Java Tiger style recommendations
Performance problems with jdk 1.5 on Linux plattform
(not tested on Windows, might be the same)
using the new style recommendations.
I need fast Vector loops for high speed mathematical calculations, some
hints about the fastest way to program that loop would be also great!
After refactoring using the new features from java 1.5 (as recommended from
SUN) I lost performance significantly:
using a vector:
public Vector<unit> units;
The new code (recommended from SUN for Java Tiger for redesign):
for (unit u: units) u.accumulate();
runs more than 30% slower than the old code:
for (int i = 0; i < units.size(); i++) units.elementAt(i).accumulate();
I expected the opposite.
Is there any information available that helps?
The following additional information I got from Mr. Shankar Unni:
I got some fairly anomalous results comparing ArrayList and Vector: for the
1.5-style loops, ArrayList was faster then Vector, but for a loop with get()
calls, Vector was faster. Vector was even faster than that using
elementAt(), which was a surprise:
For a million summing iterations over a 100-element array:
vector elementAt loop took 3446 ms.
vector get loop took 3796 ms.
vector iterator loop took 5469 ms.
arraylist get loop took 4136 ms.
arraylist iterator loop took 4668 ms.If your topic doesn't change, please stay in your original post.
-
Problem with focus border and ListCellRenderer in custom listbox
I have a bug in some code that I adapted from another posting on this board -- basically what I've done is I have a class that implements a custom "key/value" mapping listbox in which each list item/cell is actually a JPanel consisting of 3 JLabels: the first label is the "key", the second is a fixed "==>" mapping string, and the 3rd is the value to which "key" is mapped.
The code works fine as long as the list cell doesn't have the focus. When it does, it draws a border rectangle to indicate focus, but if the listbox needs to scroll horizontally to display all the text, part of the text gets cut off (i.e. "sometex..." where "sometext" should be displayed).
The ListCellRenderer creates a Gridlayout to lay out the 3 labels in the cell's JPanel.
What can I do to remedy this situation? I'm not sure what I'd need to do in terms of setting the size of the panel so that all the text gets displayed OK within the listbox. Or if there's something else I can do to fix this. The code and a main() to run the code are provided below. To reproduce the problem, click the Add Left and Add Right buttons to add a "mapping" -- when it doesn't have focus, everything displays fine, but when you give it focus, note the text on the right label gets cut off.
//======================================================================
// Begin Source Listing
//======================================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
import java.util.Enumeration;
public class TwoColumnListbox extends JPanel
private JList m_list;
private JScrollPane m_Pane;
public TwoColumnListbox(Collection c)
DataMapListModel model = new DataMapListModel();
if (c != null)
Iterator it = c.iterator();
while (it.hasNext())
model.addElement(it.next());
m_list = new JList(model);
ListBoxRenderer renderer= new ListBoxRenderer();
m_list.setCellRenderer(renderer);
setLayout(new BorderLayout());
m_list.setVisibleRowCount(4);
m_Pane = new JScrollPane(m_list);
add(m_Pane, BorderLayout.NORTH);
public JList getList()
return m_list;
public JScrollPane getScrollPane()
return m_Pane;
public static void main(String s[])
JFrame frame = new JFrame("TwoColumnListbox");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
final DataMappings dm = new DataMappings();
final TwoColumnListbox lb = new TwoColumnListbox(dm.getMappings());
final DataMap map = new DataMap();
JButton leftAddBtn = new JButton("Add Left");
leftAddBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
map.setSource("JButton1");
DefaultListModel model = new DefaultListModel();
model.addElement(map);
lb.getList().setModel(model);
JButton leftRemoveBtn = new JButton("Remove Left");
leftRemoveBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
map.setSource("");
DefaultListModel model = new DefaultListModel();
model.addElement(map);
lb.getList().setModel(model);
JButton rightAddBtn = new JButton("Add Right");
rightAddBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
map.setDestination("/getQuote/symbol[]");
DefaultListModel model = new DefaultListModel();
model.addElement(map);
lb.getList().setModel(model);
JButton rightRemoveBtn = new JButton("Remove Right");
rightRemoveBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
map.setDestination("");
DefaultListModel model = new DefaultListModel();
model.addElement(map);
lb.getList().setModel(model);
JPanel leftPanel = new JPanel(new BorderLayout());
leftPanel.add(leftAddBtn, BorderLayout.NORTH);
leftPanel.add(leftRemoveBtn, BorderLayout.SOUTH);
JPanel rightPanel = new JPanel(new BorderLayout());
rightPanel.add(rightAddBtn, BorderLayout.NORTH);
rightPanel.add(rightRemoveBtn, BorderLayout.SOUTH);
frame.getContentPane().add(leftPanel, BorderLayout.WEST);
frame.getContentPane().add(lb,BorderLayout.CENTER);
frame.getContentPane().add(rightPanel, BorderLayout.EAST);
frame.pack();
frame.setVisible(true);
class ListBoxRenderer extends JPanel implements ListCellRenderer
private JLabel left;
private JLabel arrow;
private JLabel right;
private Color clrForeground = UIManager.getColor("List.foreground");
private Color clrBackground = UIManager.getColor("List.background");
private Color clrSelectionForeground = UIManager.getColor("List.selectionForeground");
private Color clrSelectionBackground = UIManager.getColor("List.selection.Background");
public ListBoxRenderer()
setLayout(new GridLayout(1, 2, 10, 0));
//setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
left = new JLabel("");
left.setForeground(clrForeground);
arrow = new JLabel("");
arrow.setHorizontalAlignment(SwingConstants.CENTER);
arrow.setForeground(clrForeground);
right = new JLabel("");
right.setHorizontalAlignment(SwingConstants.RIGHT);
right.setForeground(clrForeground);
add(left);
add(arrow);
add(right);
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
if (isSelected)
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
left.setForeground(clrSelectionForeground);
arrow.setForeground(clrSelectionForeground);
right.setForeground(clrSelectionForeground);
else
setBackground(list.getBackground());
setForeground(list.getForeground());
left.setForeground(clrForeground);
arrow.setForeground(clrForeground);
right.setForeground(clrForeground);
// draw focus rectangle if control has focus. Problem with focus
// and cut off text!!
if (cellHasFocus)
// FIXME: for Windows LAF I'm not getting the correct thing here for some reason.
// Looks OK on Metal though.
setBorder(BorderFactory.createLineBorder(UIManager.getColor("focusCellHighlightBorder")));
else
setBorder(BorderFactory.createEmptyBorder());
DataMap map = (DataMap) value;
String displaySource = map.getSource();
String displayDest = map.getDestination();
left.setText(displaySource);
arrow.setText("=>to<=");
right.setText(displayDest);
return this;
/** Interface for macro editor UI
* @version 1.0
class DataMappings
private Collection mappings;
public DataMappings()
setMappings(new Vector(0));
public DataMappings(Collection maps)
setMappings(maps);
/** gets mapping value of a specified source object
* @param src -- the "key" or source object, what is mapped.
* @return what the source object is mapped to
* @version 1.0
public Object getValue(String src)
if (src != null)
Iterator it = mappings.iterator();
while (it.hasNext());
DataMap thisMap = (DataMap) it.next();
if (thisMap.getSource().equals(src))
return thisMap.getDestination();
return null;
/** sets mapping value of a specified source object
* @param src -- the "key" or source object, what is mapped.
* @param what the source object is to be mapped to
* @version 1.0
public void setValue(String src, String dest)
if (src != null)
// see if the value is in there first.
Iterator it = mappings.iterator();
while (it.hasNext())
DataMap thisMap = (DataMap) it.next();
if (thisMap.getSource().equals(src))
thisMap.setDestination(dest);
return;
// not in the collection, add it
mappings.add(new DataMap(src, dest));
/** gets collection of mappings
* @return a collection of all mappings in this object.
* @version 1.0
public Collection getMappings()
return mappings;
/** sets collection of mappings
* @param maps a collection of src to destination mappings.
* @version 1.0
public void setMappings(Collection maps)
mappings = maps;
/** adds a DataMap
* @param map a DataMap to add to the mappings
* @version 1.0
public void add(DataMap map)
if (map != null)
mappings.add(map);
class DataMap
public DataMap() {}
public DataMap(String source, String destination)
m_source = source;
m_destination = destination;
public String getSource()
return m_source;
public void setSource(String s)
m_source = s;
public String getDestination()
return m_destination;
public void setDestination(String s)
m_destination = s;
protected String m_source = null;
protected String m_destination = null;
/** list model for datamaps that provides ways
* to determine whether a source is already mapped or
* a destination is already mapped.
class DataMapListModel extends DefaultListModel
public DataMapListModel()
super();
/** determines whether a source is already mapped
* @param src -- the source property of a datamapping
* @return true if the source is in the list, false if not
public boolean containsSource(Object src)
Enumeration enum = elements();
while (enum.hasMoreElements())
DataMap dm = (DataMap) enum.nextElement();
if (dm.getSource().equals(src))
return true;
return false;
/** determines whether a destination is already mapped
* @param dest -- the destination property of a datamapping
* @return true if the destination is in the list, false if not
public boolean containsDest(Object dest)
Enumeration enum = elements();
while (enum.hasMoreElements())
DataMap dm = (DataMap) enum.nextElement();
if (dm.getDestination().equals(dest))
return true;
return false;
public DataMappings getDataMaps()
DataMappings maps = new DataMappings();
// add all the datamaps in the model
Enumeration enum = elements();
while (enum.hasMoreElements())
DataMap dm = (DataMap) enum.nextElement();
maps.add(dm);
return maps;
//======================================================================
// End of Source Listing
//======================================================================I did not read the program, but the chopping looks like a layout problem.
I think it's heavy to use a panel + 3 components in a gridlayout for each cell. look at this sample where i draw the Cell myself,
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class Jlist3 extends JFrame
Vector v = new Vector();
JList jc = new JList(v);
JScrollPane js = new JScrollPane(jc);
public Jlist3()
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent ev)
{ dispose();
System.exit(0);}});
for (int j=0; j < 70; j++) v.add(""+j*1000+"a d"+j);
setBounds(1,1,400,310);
getContentPane().add(js);
js.setPreferredSize(new Dimension(230,259));
jc.setSelectedIndex(1);
jc.setCellRenderer(new MyCellRenderer());
getContentPane().setLayout(new FlowLayout());
setVisible(true);
public class MyCellRenderer extends JLabel implements ListCellRenderer
String txt;
int idx;
boolean sel;
public Component getListCellRendererComponent(JList list,
Object value, // value to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus) // the list and the cell have the focus
idx = index;
txt = value.toString();
sel = isSelected;
setText(txt);
return(this);
public void paintComponent(Graphics g)
if (idx%2 == 1) g.setColor(Color.white);
else g.setColor(Color.lightGray);
if (sel) g.setColor(Color.blue);
g.fillRect(0,0,getWidth(),getHeight());
StringTokenizer st = new StringTokenizer(txt.trim()," ");
g.setColor(Color.black);
if (st.hasMoreTokens()) g.drawString(st.nextToken(),1,14);
g.setColor(Color.red);
g.drawString("===>",70,14);
g.setColor(Color.black);
if (st.hasMoreTokens()) g.drawString(st.nextToken(),110,14);
public static void main (String[] args)
new Jlist3();
Noah
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class Jlist3 extends JFrame
Vector v = new Vector();
JList jc = new JList(v);
JScrollPane js = new JScrollPane(jc);
public Jlist3()
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent ev)
{ dispose();
System.exit(0);}});
for (int j=0; j < 70; j++) v.add(""+j*1000+"a d"+j);
setBounds(1,1,400,310);
getContentPane().add(js);
js.setPreferredSize(new Dimension(230,259));
jc.setSelectedIndex(1);
jc.setCellRenderer(new MyCellRenderer());
getContentPane().setLayout(new FlowLayout());
setVisible(true);
public class MyCellRenderer extends JLabel implements ListCellRenderer
String txt;
int idx;
boolean sel;
public Component getListCellRendererComponent(JList list,
Object value, // value to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus) // the list and the cell have the focus
idx = index;
txt = value.toString();
sel = isSelected;
setText(txt);
return(this);
public void paintComponent(Graphics g)
if (idx%2 == 1) g.setColor(Color.white);
else g.setColor(Color.lightGray);
if (sel) g.setColor(Color.blue);
g.fillRect(0,0,getWidth(),getHeight());
StringTokenizer st = new StringTokenizer(txt.trim()," ");
g.setColor(Color.black);
if (st.hasMoreTokens()) g.drawString(st.nextToken(),1,14);
g.setColor(Color.red);
g.drawString("===>",70,14);
g.setColor(Color.black);
if (st.hasMoreTokens()) g.drawString(st.nextToken(),110,14);
public static void main (String[] args)
new Jlist3();
}
Maybe you are looking for
-
How do I get the bookmarks to automatically appear in the toolbar?
When my computer updated firefox, the entire tookbar disappeared. I want to know how to reinstate the tool bar with my bookmarks.
-
RFC Communication error when doing initial indexing
Hello Everyone, I have a quick question, when doing the initial index rollup for a BIA index the job is failing with RFC communication error. We currently have the setting related to " TREXRfcServer threads" set to "Automatic Changes" in order to avo
-
How do i get limewire downloads to update to my itune library automatically
i download music from limewire and i am trying to get my itune to recunize the new downloads. the only way it will go to my itunes is if i listen to it in my shared foler. itune is my defalt player.
-
Recovering deleted photos - Any way??
Photos lost from iPhoto in the upgrade process (still not sure how). They were on my iPhone, but when it synced, they were lost. Is there a way to access the iPhone as a hard drive and recover the photos, if they are still there? Or is that not even
-
How to creating checkbox on SAP B1
Hello Experts, Please tell me how to create check-box in table.. I have machines more than 100 and for creating quotation i have to choose machine and its part say 10 out of 100 so in this case we do select parts by pressing CTRL key but what happens