How to display an indication of unprintable Ascii code in Lookout 5.0
Hi,
I am receving response telegram in unprintable Ascii characters such as correct response is ACK(hex06) or resonse in case of error NAK(hex15). I want to display such responses in signal indicator. For example response is ACK, the LED is on, otherwise the LED is off.
I set an expression for the object LED as followed: if(ASCII1.Response="\x06",1,0), but the indicator is not working as I expected. Anyone has good ideas to help me in this case?
Thanks alot
Hi,
I am receving response telegram in unprintable Ascii characters such as correct response is ACK(hex06) or resonse in case of error NAK(hex15). I want to display such responses in signal indicator. For example response is ACK, the LED is on, otherwise the LED is off.
I set an expression for the object LED as followed: if(ASCII1.Response="\x06",1,0), but the indicator is not working as I expected. Anyone has good ideas to help me in this case?
Thanks alot
Similar Messages
-
How to display the data of CJ2C(T-CODE) using web dynpro abap
Hi all:
How to display the data of CJ2C(T-CODE) using web dynpro abap.
CJ2C used to display a Gantt Chart.
Thanks.Hi,
Create a Value attribute (resource) of type Resource, bind it with the property of File Upload UI element.
On action place the code and Deploy the application
byte[] bytes = new byte[ 1024];
FileOutputStream out = new FileOutputStream( new File( <path in server>));
InputStream in = resource.read( true);
int len;
while( ( len = in.read( bytes)) > 0)
out.write( bytes, 0, len);
in.close();
out.close();
Regards
Vinod V -
How to display a popup window (DialogMessage) via code behind c#?
hi all,
How to display a popup window (DialogMessage) via code behind c#?
I use sp 2013, in else case I want show the DialogMessage:
if(condition)
else
HttpContext.Current.Response.Redirect(SPContext.Current.Web.Url+"/_layouts/TestError/ErrorDueDate.aspx");
the above Redirect work good but I want show the error in a DialogMessage its better because of Usability and not redirect the user to new page...
if not via code behind is there a better way to do it?
thanks in advance
Ahmad
SP 2013 & SPD 2013 & VS 2013 & MSSQL 2012thanks for you answer,
And yes I includ them via CDN, like below:
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js"
type="text/javascript"></script>
<link
href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
rel="stylesheet" type="text/css"
/>
But I get still the above error in my previes post.
SP 2013 & SPD 2013 & VS 2013 & MSSQL 2012 -
How to Make PAP2T Send INVITE With ASCII Codes?
Want to dial #31#22 to activate call forwarding. Want the PAP2T TA to send the To field of the invite with %2331%2322
The %23 in the To is the ASCII conversion of the # symbol. When dialing this on the PAP2T the To field of the invite looks like #31#22.
According to the RFC this is not correct, the # symbols should be sent by the TA as %23.
What do you have to set on the TA to get this ASCII code conversion?Want to dial #31#22 to activate call forwarding. Want the PAP2T TA to send the To field of the invite with %2331%2322
The %23 in the To is the ASCII conversion of the # symbol. When dialing this on the PAP2T the To field of the invite looks like #31#22.
According to the RFC this is not correct, the # symbols should be sent by the TA as %23.
What do you have to set on the TA to get this ASCII code conversion? -
How do I get labview for linux to send out ascii code to a motion controller?
I have posted part of this problem but I will now try to clearify things. I have an x-y stage that needs motion control. I have to run the motion controller from within a linux system (RedHat 7.1) due to others in the research area. I have found a motion controller card (PCI) that will run under linux. This card is not National Instruments. I understand that they do not have drivers for their controller cards. This other card comes with the companies own software that uses ASCII codes to move the motors on the stage. I was hoping to create a program that could call those ASCII codes to move the stage. An example would be if a user wanted to have the stage move to the right he would press a b
utton on the screen instead of typing in whatever ASCII could that move to the right happens to be. How would I go about programming something like this? I have heard of others doing things like this but I am unsure of how to program labview to send out ASCII codes to a PCI card to move motors.> would I go about programming something like this? I have heard of
> others doing things like this but I am unsure of how to program
> labview to send out ASCII codes to a PCI card to move motors.
Look in the manual to see get familiar with the sequences of codes you
need to write, and more importantly, where you write them to. I suspect
a memory location, but it could be a socket or port.
Each of these locations will have a slightly different way of accessing
it. Once you know, search devzone for how to do it on linux, or post
back here.
After you can send the codes to the right location, you probably want to
build a state machine that simplifies the interface and prevents certain
actions from taking place. Now determine which buttons or
keys perform
which actions and use either the event structure or the older polling
for control changes to affect state changes in the state machine.
I'm summarizing here assuming that you know what a state machine is and
why you'd want to use it. If I'm assuming too much, do some research
and post again with more specific questions. Also be sure to look at
example VIs as they show how to respond to UI actions.
Greg McKaskle -
How to display raw, not ascii, bytes from serial port?
Hello, I have an instrument that outputs raw data, not ascii, bytes to a serial port. How do you display raw data, not ascii, bytes from a serial port? Since raw data bytes are not displayable, there is got to be something in labview to interpret/display the received bytes the way it is as data in HEX or Binary. The STRING-TO-HEX and STRING-TO-BINARY functions are not applicable in this case because the bytes were not string type in the first place. For example, if the receive byte is 0x4D, I need to display 4D in HEX or 77 in Decimal and not the ascii character "M" corresponding to 0x4D ascii code. I am using a VISA-RD function currently to receive the data from a COM port. VISA-RD outputs string type. Thank for any feedback or suggestion in advance.
BC@Baxter wrote:
...The STRING-TO-HEX and STRING-TO-BINARY functions are not applicable in this case because the bytes were not string type in the first place...
Of course they are string type, just not formatted in a human readable form. So, YES, these functions are not appropriate.
BC@Baxter wrote:
For example, if the receive byte is 0x4D, I need to display 4D in HEX or 77 in Decimal and not the ascii character "M" corresponding to 0x4D ascii code.
Dennis is right, but there is no "decimal" display for strings, so the second requirement needs a tiny little bit more code.
If you have a single byte string, you can typecast it into a U8 number and set the display format as decimal, hex, octal, or binary as desired. In decimal, it would display the number 77. Since it is now a numeric, you can even do math with it.
In general, the string has multiple bytes, and you would typecast it into an array of U8 numbers (Since this is an often used function, there is also a "string to byte array" which does the same thing).
Typecasting is the secret. You can e.g. easily typecast 2 bytes into a U16, 4 bytes into a I32, 8 bytes into a DBL, etc. For more detailed requirements, there is also the "unflatten from string". Check the online help for details. Good luck!
LabVIEW Champion . Do more with less code and in less time . -
How to display char code properly?
Hi all,
I am trying to convert the decimal numebr (0 to 127) to a char (ASCII code). I found the code here http://digital.ni.com/public.nsf/allkb/894CF5FE064971BF8625758400014993
I try with several numbers but it doesn't shown the same character as shown in http://digital.ni.com/public.nsf/allkb/475C4E4F3A638AA58625795F007EC531?OpenDocument
For example, I tried 104, it shows "@ " but it should be "h". I tried 33, it shows "@" but it should be "!" (no quotation). I wonder what's the right way to do the converstion or is it the wrong way to display it?
By the way, if I have an array for decimal numbers, besides using loop and code like above to convert all of them to ASCII one by one, is that any faster way to do the conversion? Thanks.
Solved!
Go to Solution.johnsold wrote:
PKIM,
Typecast is not the function to use for what you want to do. It forces the binary representation of the data to be re-interpreted as a different datatype. The Extended datatype is particularly problematic as it uses different binary representations on different platforms.
1. You should use a binary datatype, specifically U8, for numbers which will be converted to characters in a string.
2. If the input is U8, typecast to string actually works.
3. For an array (of U8) use the Byte Array to String function.
4. To convert a string to an array of U8 use the complemantary String to Byte Array function.
5. These functions may be found in Nuumeric >> Conversion or String >> Path/Array/String Conversion palettes/
Lynn
Thanks johnsold, it does help. I have a question about the data conversion. If the array of interger is a word (two-byte integer) and I would like to convert each byte of the word to ASCII. How can I do that? I mean how can I extract the first 8 bits and bit 8 to bit 15 from a word in labview? It is pretty easy to do so in C/C++ but I don't know how to do that in labview. -
How to display double byte characters with system.out.print?
Hi, I'm a newbie java programmer having trouble to utilize java locale with system io on dos console mode.
Platform is winxp, jvm1.5,
File structure is:
C:\myProg <-root
C:\myProg\test <-package
C:\myProg\test\Run.java
C:\myProg\test\MessageBundle.properties <- default properties
C:\myProg\test\MessageBundle_zh_HK.properties <- localed properties (written in notepad and save as Unicode, window notepad contains BOM)
inside MessageBundle.properties:
test = Hello
inside Message_zh_HK.properties:
test = 喂 //hello in big5 encoding
run.java:
package test;
import java.util.*;
public class Run{
public static void main(String[] args){
Locale locale = new Locale("zh","HK");
ResourceBundle resource =
ResourceBundle.getbundle("test.MessageBundle", locale);
System.out.println(resource.getString("test"));
}//main
}//classwhen run this program, it'll kept diplay "hello" instead of the encoded character...
then when i try run the native2ascii tool against MessageBundle_zh_HK.properties, it starts to display monster characters instead.
Trying to figure out what I did wrong and how to display double byte characters on console.
Thank you.
p.s: while googling, some said dos can only can display ASCII. To demonstrate the dos console is capable of displaying double byte characters, i wrote another helloWorld in chinese using notepad with C# and compile using "csc hello.cs", sure enough, console.write in c# allowed me to display the character I was expecting. Since dos console can print double byte characters, I must be missing something important in this java program.after google a brunch, I learned that javac (hence java.exe) does not support BOM (byte order mark).
I had to use a diff editor to save my text file as unicode without BOM in order for native2ascii to convert into a ascii file.
Even the property file is in ascii format, I'm still having trouble to display those character in dos console. In fact, I just noticed I can use system.out.println to display double byte character if I embedded the character itself in java source file:
public class Run {
public static void main(String[] args) throws UnsupportedEncodingException{
String msg = "中文"; //double byte character
try{
System.out.println(new String(msg.getBytes("UTF-8")) + " new string"); //this displays fine
catch(Exception e){}
Locale locale = new Locale("zh", "HK");
ResourceBundle resource = ResourceBundle.getBundle("test.MessagesBundle", locale);
System.out.println(resource.getString("Hey")); //this will display weird characterso it seems like to me that I must did something wrong in the process of creating properties file from unicode text file... -
Idoc-xi-file scenario. how to display file in html format
I am not sure whether this is a valid question.........but want to confirm as it was asked by somebody
In idoc-xi-file scenario....... how to display file in html format ??
Thanks in advance
KumarHi Vijayakumar,
Thanks for your reply !! You mean to say I got to use XSLT mapping and also .htm and .html extension together to produce the html file ?? or it is sufficient to use any one of them to produce the html file ??
Regards
Kumar -
In sap scripts how to display the driver program
Hi,
I Want to know the sap scripts How to display the output to driver programHi,
Go to NACE Transaction.
Select application for ex: if sales V1.
Click on output types.
Select the output type for ex : BA00
Double click on Processing routines.
There you can find the Driver Program name and Script/smart form name.
Reward if useful.
Thanks,
Raju -
How to display username in RTF BI publisher report?
Please advice how to display username in RTF BI publisher report?
May be this can be done via hidden parameter of BIP report which default value will be set up with macro like {$username$} (or smth like)?
Thanks in advance!Thanks. That worked. I was trying to get it as part of a multi-table query, aliasing dual. But that doesn't work in SQL Plus either so I guess I can't do that.
I was trying
select o.*, d.:xdo_user_name
from oblix_audit_events o, dual d
Before that I was trying
select
:xdo_user_name as USER_ID,
:xdo_user_roles as USER_ROLES,
:xdo_user_report_oracle_lang as REPORT_LANGUAGE,
:xdo_user_report_locale as REPORT_LOCALE,
:xdo_user_ui_oracle_lang as UI_LANGUAGE,
:xdo_user_ui_locale as UI_LOCALE
from dual
but I must have fat fingered something because that works now too. Thanks.
So if I need to do this in it's own query and I'm using an RTF template, how do I make that work?
If I have to do it with it's own -
How to display and edit the clob datatype column from Data base
Hi ,
I have a requiremsnt as below
1) One Table having some columns with CLOB data type along with varchar columns
2) need to display the data from DB in search screen and need to be edited clob column in edit screen
I created EO and VO with that Table and how to display the clob value into the input box for editing.
using Jdev 11.1.1.5.0 version.
Can you please help on this.
THanks & REgards,
MadhuHi,
If you are using an inputText component to display a Character Large Object (CLOB), then you will need to create a custom converter that converts the CLOB to a String.
For custom convertor refer below link,
http://docs.oracle.com/cd/E2438201/web.1112/e16181/af_validate.htm#BABGIEDH
(section7.4 Creating Custom JSF Converters)
Thanks,
Santosh M E -
How to display URL images and URL link (html) from Smartforms?
Hi Gurus,
I'm having difficulty on how to display targeted URL images and URL link from the smartforms, after i sending it out as html mail. The mail i sent just can be preview as a plain text, which can't execute the html code that i put inside the smartforms itself. I follow a few step from this very useful blog.. Hopefully, you guys can give me some solutions or ideas on this.
/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp -thanks to Pavan for his useful blog.
My code is like this..
<--- Start Code.
FORM call_smartforms.
DATA : lv_subject TYPE so_obj_des,
lc_true(1) VALUE 'X',
lw_control_parameters TYPE ssfctrlop,
lw_output_options TYPE ssfcompop,
lc_graphics(8) VALUE 'GRAPHICS',
lw_xsfparam_line TYPE ssfxsfp,
lc_extract(7) VALUE 'EXTRACT',
lc_graphics_directory(18) VALUE 'GRAPHICS-DIRECTORY',
lc_mygraphics(11) VALUE 'mygraphics/',
lc_content_id(10) VALUE 'CONTENT-ID',
lc_enable(6) VALUE 'ENABLE',
lw_job_output_info TYPE ssfcrescl,
lw_html_data TYPE trfresult,
lw_graphics TYPE ssf_xsf_gr,
lt_graphics TYPE tsf_xsf_gr,
lv_html_xstr TYPE xstring,
lw_html_raw LIKE LINE OF lw_html_data-content,
lv_incode TYPE tcp00-cpcodepage VALUE '4110',
lv_html_str TYPE string,
lv_html_len TYPE i,
lc_utf8(5) VALUE 'utf-8',
lc_latin1(6) VALUE 'latin1',
lv_offset TYPE i,
lv_length TYPE i,
lv_diff TYPE i,
lt_soli TYPE soli_tab,
lw_soli TYPE soli,
lc_mime_helper TYPE REF TO cl_gbt_multirelated_service,
lv_name TYPE mime_text VALUE 'sapwebform.htm',
lv_xstr TYPE xstring,
lw_raw TYPE bapiconten,
lt_solix TYPE solix_tab,
lw_solix TYPE solix,
lv_filename TYPE string,
lv_content_id TYPE string,
lv_content_type TYPE w3conttype,
lv_obj_len TYPE so_obj_len,
lv_bmp TYPE so_fileext VALUE 'BMP',
lv_description TYPE so_obj_des VALUE 'Graphic in BMP format',
lc_doc_bcs TYPE REF TO cl_document_bcs,
lc_bcs TYPE REF TO cl_bcs,
lc_send_exception TYPE REF TO cx_root,
lw_adsmtp TYPE lty_adsmtp,
lv_mail_address TYPE ad_smtpadr,
lc_recipient TYPE REF TO if_recipient_bcs,
lc_send_request TYPE REF TO cl_bcs,
lv_sent_to_all TYPE os_boolean.
DATA : v_language TYPE sflangu VALUE 'E',
v_e_devtype TYPE rspoptype.
v_form_name = 'ZTEST_EMAIL'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = v_form_name
IMPORTING
fm_name = v_namef
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc = 0.
break mhusin.
ENDIF.
starting here. ***
Set title for the output
lv_subject = 'Smartforms.'.
Set control parameters to "no dialog"
lw_control_parameters-no_dialog = lc_true.
IF lw_service_subject-code = lc_fm1.
*--- To get output device type
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = v_language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = v_e_devtype.
lw_output_options-tdprinter = v_e_devtype.
lw_control_parameters-getotf = 'X'.
IF sy-subrc = 0.
break mhusin.
ENDIF.
Set output options
lw_output_options-xsf = lc_true.
lw_output_options-xsfcmode = lc_true.
lw_output_options-xsfoutmode = 'A'.
lw_output_options-xsfoutdev = space.
lw_output_options-xsfformat = lc_true.
lw_xsfparam_line-name = lc_graphics.
lw_xsfparam_line-value = lc_extract.
APPEND lw_xsfparam_line TO lw_output_options-xsfpars.
lw_xsfparam_line-name = lc_graphics_directory.
lw_xsfparam_line-value = lc_mygraphics.
APPEND lw_xsfparam_line TO lw_output_options-xsfpars.
lw_xsfparam_line-name = lc_content_id.
lw_xsfparam_line-value = lc_enable.
APPEND lw_xsfparam_line TO lw_output_options-xsfpars.
Get the smartform content
CALL FUNCTION v_namef
EXPORTING
control_parameters = lw_control_parameters
output_options = lw_output_options
*pass other application specific parameters (eg order number, items ).
IMPORTING
job_output_info = lw_job_output_info
TABLES
tt_tabh = tt_tabh
tt_tabb = tt_tabb
tt_tabf = tt_tabf
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc = 0.
break mhusin.
ENDIF.
lw_html_data = lw_job_output_info-xmloutput-trfresult.
lt_graphics[] = lw_job_output_info-xmloutput-xsfgr[].
CLEAR lv_html_xstr.
LOOP AT lw_html_data-content INTO lw_html_raw.
CONCATENATE lv_html_xstr lw_html_raw INTO lv_html_xstr IN BYTE MODE.
ENDLOOP.
lv_html_xstr = lv_html_xstr(lw_html_data-length).
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
inbuff = lv_html_xstr
incode = lv_incode
csubst = lc_true
substc_space = lc_true
IMPORTING
outbuff = lv_html_str
outused = lv_html_len
EXCEPTIONS
OTHERS = 1.
*HACK THE HTML CODE GENERATED BY SMARTFORM TO MAKE THE
*EXTERNAL IMAGES APPEAR AS <IMG> TAG IN HTML
REPLACE ALL OCCURRENCES OF '<IMG' IN lv_html_str WITH '<IMG' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '/>' IN lv_html_str WITH '/>' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '</A>' IN lv_html_str WITH '' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<' IN lv_html_str WITH '<' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '>' IN lv_html_str WITH '>' IGNORING CASE.
CALL METHOD html_control - >load_mime_object
EXPORTING
object_id = 'ZWN'
object_url = 'ZWN.GIF'
EXCEPTIONS
OTHERS = 1.
REPLACE ALL OCCURRENCES OF lc_utf8 IN lv_html_str WITH lc_latin1.
REPLACE ALL OCCURRENCES OF lc_utf8 IN lv_html_str WITH 'iso-8859-1'.
break mhusin.
lv_html_len = STRLEN( lv_html_str ).
lv_offset = 0.
lv_length = 255.
WHILE lv_offset < lv_html_len.
lv_diff = lv_html_len - lv_offset.
IF lv_diff > lv_length.
lw_soli-line = lv_html_str+lv_offset(lv_length).
ELSE.
lw_soli-line = lv_html_str+lv_offset(lv_diff).
ENDIF.
APPEND lw_soli TO lt_soli.
ADD lv_length TO lv_offset.
ENDWHILE.
CREATE OBJECT lc_mime_helper.
CALL METHOD lc_mime_helper->set_main_html
EXPORTING
content = lt_soli
filename = lv_name
description = lv_subject.
LOOP AT lt_graphics INTO lw_graphics.
CLEAR lv_xstr.
LOOP AT lw_graphics-content INTO lw_raw.
CONCATENATE lv_xstr lw_raw-line INTO lv_xstr IN BYTE MODE.
ENDLOOP.
lv_xstr = lv_xstr(lw_graphics-length).
lv_offset = 0.
lv_length = 255.
CLEAR lt_solix[].
WHILE lv_offset < lw_graphics-length.
lv_diff = lw_graphics-length - lv_offset.
IF lv_diff > lv_length.
lw_solix-line = lv_xstr+lv_offset(lv_length).
ELSE.
lw_solix-line = lv_xstr+lv_offset(lv_diff).
ENDIF.
APPEND lw_solix TO lt_solix.
ADD lv_length TO lv_offset.
ENDWHILE.
CONCATENATE lc_mygraphics lw_graphics-graphics text-001 INTO lv_filename.
CONCATENATE lc_mygraphics lw_graphics-graphics text-001 INTO lv_content_id.
lv_content_type = lw_graphics-httptype.
lv_obj_len = lw_graphics-length.
*Add images to the email
CALL METHOD lc_mime_helper->add_binary_part
EXPORTING
content = lt_solix
filename = lv_filename
extension = lv_bmp
description = lv_description
content_type = lv_content_type
length = lv_obj_len
content_id = lv_content_id.
ENDLOOP.
TRY.
lv_subject = lv_subject.
lc_doc_bcs = cl_document_bcs=>create_from_multirelated(
i_subject = lv_subject
i_multirel_service = lc_mime_helper ).
CATCH cx_document_bcs INTO lc_send_exception.
CATCH cx_bcom_mime INTO lc_send_exception.
CATCH cx_gbt_mime INTO lc_send_exception.
ENDTRY.
Create send request
TRY.
lc_bcs = cl_bcs=>create_persistent( ).
CATCH cx_send_req_bcs INTO lc_send_exception.
ENDTRY.
TRY.
lc_bcs->set_document( i_document = lc_doc_bcs ).
CATCH cx_send_req_bcs INTO lc_send_exception.
ENDTRY.
Set-up email receiver
lv_mail_address = '[email protected]'.
TRANSLATE lv_mail_address TO UPPER CASE.
TRY.
lc_recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = lv_mail_address ).
CATCH cx_address_bcs INTO lc_send_exception.
ENDTRY.
TRY.
lc_bcs->add_recipient( i_recipient = lc_recipient ).
CATCH cx_send_req_bcs INTO lc_send_exception.
ENDTRY.
Send smartforms as HTML email
TRY.
lc_bcs->send( ).
CATCH cx_send_req_bcs INTO lc_send_exception.
ENDTRY.
COMMIT WORK.
WRITE:/ 'Mail sent'.
ENDFORM. "call_smartforms
End Code --->
Thanks and Regards.1- put your images in a directory under the web app directory. Example: app/images/
2- in your jsp, use: String file = application.getRealPath("/images/"); to get the images directory. See http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
3- it's not the right forum to post this kind of question. Post them in the JSP/Servlet JSTL forum instead -
How to Display Excel Report in Client machine in Forms11g
Hi All,
we are running database in Linux server and separate Linux Application Server , But my question is how to display the data to Excel Report in the Client machine
in Forms11g applications.
Plesase suggest any method.
Regards
Venkatesulu GunisettyYou should use webutils.
For proper answer, place ur request here in oracle Forms Thread,
Forms -
Please Help::How to display a Map with LIsts as Keys and Values using JSTL
Hi,
I need some assistance on how to display a Map in JSP using struts or core JSTL. I have a HashMap which has a List of keys and each key maps to a value of an ArrayList.i.e I have an ArrayList of taxCodes and each taxCode maps to a value of taxDetails which is an ArrayList of details for for that particular taxCode. I have some trouble to display each taxCode then display taxDetails for each taxCode. Here is my code below:
OrderDetails.java
package orderitems;
import java.sql.*;
import java.util.*;
public class OrderDetails {
private LineOder lineOrder;
private Map lineItems;
//returns an item number, key_item, from its unique keys
public int getItemNumber(int key_item, String key_year,
String key_office,String key_client,String key_company){
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
int itmNum = 0;
* key_item a unique number for an item.
* key_year,key_office,key_client,key_company unique keys
* for each order where this key_item is taken
* from.
String select = "SELECT key_item FROM "+
Constants.WEB_TABLE +" WHERE key_item = " + key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
if(rst.next()){
itmNum = Integer.parseInt(rst.getString("key_item"));
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itmNum;
//get a list of item number(item codes)
public List getAllItemNumbers(String key_year,
String key_office,String key_client,String key_company){
List itemNumbers = new ArrayList();
LineItem itemNumber = null;
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
String select = "SELECT key_item FROM "+ Constants.WEB_TABLE +
" WHERE key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company + "'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
itemNumber = new LineItem();
itemNumber.setKey_item(Integer.parseInt(rst.getString("key_item")));
itemNumbers.add(itemNumber);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itemNumbers;
//get a list of tax codes
public List getAllTaxCodes(int key_item, String key_year,
String key_office,String key_client,String key_company){
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
ItemTax taxCode;
List taxCodes = new ArrayList();
int itemNum = getItemNumber(key_item, key_year,
key_office,key_client,key_company);
String select = "SELECT key_tax_code FROM "+
Constants.WEB_TABLE +" WHERE key_item = " + itemNum +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
taxCode = new ItemTax();
taxCode.setKey_tax_code(rst.getString("key_tax_code"));
taxCodes.add(taxCode);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return taxCodes;
/////This methode returns a Map which am trying to display in JSP
//use tax code to get tax details
public Map getItemTaxDetails(String key_year,String key_office,
String key_client,String key_company,int key_item){
ItemTax taxDetail = null;
List taxDetails = new ArrayList();
List itemTaxCodes = new ArrayList();
Map itemTaxDetails = new HashMap();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//get a list of all tax codes of an item with a
//given item number
itemTaxCodes = getAllTaxCodes(key_item,key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
String taxCode = itemTaxCode.getKey_tax_code();
String select = "SELECT tax_type,tax_value," +
"tax_limit_val FROM "+ Constants.WEB_TABLE +
" WHERE key_item = "+ key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'" +
" AND key_tax_code = '" + taxCode + "'";
rst = stat.executeQuery(select);
while(rst.next()){
taxDetail = new ItemTax();
//records to be displayed only
taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
taxDetail.setTax_value(rst.getString("tax_value"));
taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
//////other details records ommited//////////////////////////
taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
* A HashMap which has all taxCodes of an item as its keys
* and an ArrayList of taxdetails as its values.
* I return this for display in a JSP.
itemTaxDetails.put(taxCode,taxDetails);
System.out.println();
System.out.println("*********CONSOLE OUTPUT*************");//display on console
Set set = itemTaxDetails.keySet();
Iterator iter = set.iterator();
System.out.println("Key\t\tValue\r\n");
while (iter.hasNext()) {
Object taxCode=iter.next();
Object details=itemTaxDetails.get(taxCode);
System.out.println(taxCode +"\t" + details);
System.out.println("************************************");
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return itemTaxDetails;
//details of an item with all its taxes
public List getAllItemDetails(String key_year,
String key_office,String key_client,String key_company){
List lineItems = new ArrayList();
List itemNumbers = new ArrayList();
Map taxDetails = new HashMap();
LineItem item = null;
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//A list of all item numbers in the declaration
itemNumbers = getAllItemNumbers(key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator itemIter= itemNumbers.iterator(); itemIter.hasNext();){
LineItem itemNum = (LineItem)itemIter.next();
int itemNumber = itemNum.getKey_item();
String select = "SELECT item_description,item_mass," +
"item_cost" +
" FROM " + Constants.WEB_TABLE +
" WHERE key_year = '"+key_year+"'" +
" AND key_office = '"+key_office+ "'"+
" AND key_client = '"+key_client+ "'"+
" AND key_company = '"+key_company+ "'"+
" AND key_item = " + itemNumber;
rst = stat.executeQuery(select);
while(rst.next()){
item = new LineItem();
item.setItem_description(rst.getString("item_description"));
item.setItem_mass(Float.parseFloat(rst.getString("item_mass")));
item.setKey_item(Integer.parseInt(rst.getString("item_cost")));
//////other details records ommited//////////////////////////
/* A HashMap of all itemTaxeCodes as its keys and an
* ArrayList of itemTaxedetails as its values
taxDetails = getItemTaxDetails(item.getKey_year(),item.getKey_office(),
item.getKey_client(),item.getKey_company(),item.getKey_item());
//item tax details
item.setItmTaxes(taxDetails);
//list of items with tax details
lineItems.add(item);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return lineItems;
public Set getOrders(String key_year,String key_office,
String key_client,String key_company){
List lineItems = new ArrayList();
Set lineOrders = new HashSet();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
LineOder lineOrder = null;
String select = "SELECT * FROM " + Constants.WEB_TABLE +
" WHERE key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company + "'";
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
rst = stat.executeQuery(select);
while(rst.next()){
lineOrder = new LineOder();
lineOrder.setKey_year(rst.getString("key_year"));
lineOrder.setKey_office(rst.getString("key_office"));
lineOrder.setKey_client(rst.getString("key_client"));
lineOrder.setKey_company(rst.getString("key_company"));
////list of items with all their details
lineItems = getAllItemDetails(lineOrder.getKey_year(),lineOrder.getKey_office(),
lineOrder.getKey_client(),lineOrder.getKey_company());
//setting item details
lineOrder.setItems(lineItems);
//a list of order with all details
lineOrders.add(lineOrder);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
return lineOrders;
Controller.java
package orderitems;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Controller extends HttpServlet {
private Map taxDetails = new HashMap();
private OrderDetails orderDetails = null;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String key_year = "2007";
String key_office = "VZX00";
String key_company = "DG20";
String key_client = "ZI001";
int key_item = 1;
String nextView = "/taxdetails_list.jsp";
orderDetails = new OrderDetails();
taxDetails = orderDetails.getItemTaxDetails(key_year,key_office,
key_company,key_client,key_item);
//Store the collection objects into HTTP Request
request.setAttribute("taxDetails", taxDetails);
RequestDispatcher reqstDisp =
getServletContext().getRequestDispatcher(nextView);
reqstDisp.forward(request,response);
protected void doGet(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
processRequest(request, response);
protected void doPost(HttpServletRequest request,
HttpServletResponse response)throws
ServletException, IOException {
processRequest(request, response);
taxdetails_list.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Simple Tax Detail Diaplay ::</title>
<link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
</head>
<body>
<jsp:useBean id="taxDetails" class="java.util.HashMap" scope="request"/>
<table>
<c:forEach items="${taxDetails}" var="hMap">
<tr>
<td><c:out value="${hMap.key}" /></td>
<!--td><%--c:out value="${hMap.value}" /--%></td-->
</tr>
</c:forEach>
</table>
</body>
</html>am displaying taxCodes(in this case i have VAT and ICD) fine but cant figure out how to display a list of value for each taxCode.Here is the output am getting
both in my JSP and on the console:
*******************************CONSOLE OUTPUT****************************
Key Value
ICD [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
VAT [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
Edited by: aiEx on Oct 8, 2007 6:54 AMhi evnafets,
yes i need a nested for loop.I have tried your advice but my bean properties are not found.Am getting this error:
javax.servlet.ServletException: Unable to find a value for "key_item" in object of class "java.lang.String" using operator "."
I have tried this as stated earlier in the post:I have tried to make the method getItemTaxDetails return a List and get the returned list value as taxDetails. I then tested to display this list on JSP and its displaying fine.
public List getItemTaxDetails(String key_year,String key_office,
String key_client,String key_company,int key_item){
ItemTax taxDetail = null;
List taxDetails = new ArrayList();
List itemTaxCodes = new ArrayList();
Map itemTaxDetails = new HashMap();
Connection conn = null;
Statement stat = null;
ResultSet rst = null;
//get a list of all tax codes of an item with a
//given item number
itemTaxCodes = getAllTaxCodes(key_item,key_year,
key_office,key_client,key_company);
DbConnection dbConn = new DbConnection();
try {
conn = dbConn.getDbConnection(Constants.WEB_JNDI);
stat = conn.createStatement();
for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
String taxCode = itemTaxCode.getKey_tax_code();
String select = "SELECT tax_type,tax_value," +
"tax_limit_val FROM "+ Constants.WEB_TABLE +
" WHERE key_item = "+ key_item +
" AND key_year = '" + key_year + "'" +
" AND key_office = '" + key_office + "'" +
" AND key_client = '" + key_client + "'" +
" AND key_company = '" + key_company +"'" +
" AND key_tax_code = '" + taxCode + "'";
rst = stat.executeQuery(select);
while(rst.next()){
taxDetail = new ItemTax();
//records to be displayed only
taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
taxDetail.setTax_value(rst.getString("tax_value"));
taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
//////other details records ommited//////////////////////////
taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
* A HashMap which has all taxCodes of an item as its keys
* and an ArrayList of taxdetails as its values.
* I return this for display in a JSP.
itemTaxDetails.put(taxCode,taxDetails);
} catch (SQLException ex) {
ex.printStackTrace();
} finally{
SQLHelper.cleanUp(rst, stat, conn);
//return itemTaxDetails;
return taxDetails;
}And my JSP
taxdetails_list.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
</head>
<body>
<table>
<c:forEach var="curRecord" items="${taxDetails}" varStatus="rowCounter">
<c:choose>
<c:when test="${rowCounter.count % 2 == 0}">
<c:set var="rowStyle" scope="page" value="odd" />
</c:when>
<c:otherwise>
<c:set var="rowStyle" scope="page" value="even" />
</c:otherwise>
</c:choose>
<tr class="${rowStyle}">
<td>${curRecord.key_item}</td>
<td>${curRecord.tax_value}</td>
<td>${curRecord.tax_limit_val}</td>
</tr>
</c:forEach>
</table>
</body>
</html>I can't see where am going wrong even with your advice.Please help.
Thnx.
Maybe you are looking for
-
After I uninstall and reinstall Firefox works for a few executions but when I try to run it after about an hour or so it does not respond, does not give me any message. I have deleted my old profile, upon uninstalling I checked the box which asks if
-
Reopen all windows from last session - NOT WORKING
Why will this not work?
-
ITunes 10.7 update kills wifi on Win7
I've fixed a problem I was having and hope that maybe this thread helps someone else having a similar issue. My computer has Win7 with all the updates as I do updates religiously as soon as I'm notified there's something to install. My wifi connectio
-
Mac Network does not work properly, can't safe, access only in safemode
Hi guys I just got a nice IMac 27" and really like it. Now I set up a network to move files back and forth with my Macbook Pro. Now I encounter the following problems: - I can not safe files on the IMac from my Macbook - Access to files on IMac are o
-
PBG4 with 'missing / dissapearing' disk space issue
My wife's powerbook appears to have 'missing' hard disk space and I can't figure out why. Here is the information from System Profiler about her only hard drive in the computer. Capacity: 74.41 GB Available: 6.91 GB Writable: Yes File System: Journal