How to store attachments in CAF?
Hi, all.
I implemented a wd app to let user upload some attachments and I wanted to store the attachments with CAF. In my wd app, I declared a wdresource to ctach the uploaded attachment. What type should I use for my BO`s attribute to store the attachment?
Thx a lot.
Hello!
The BASE64BINARY is the perfect to do it, but please note we have the BO type Document and we don´t need to transport full archive all time we use these objects, that´s because when i use a BASE64BINARY i am carry full archive on hard code, the type Document we´ll reference a local where stay the file and some properties about him.
Off course for the use of any one depends what do you´ll do with they.
I hope i helped you.
Best regards,
Ronaldo Rampelotti
Similar Messages
-
How to store Multiple Attachments in Workflow.
Hello All,
I am doing an scenario, in that i need to store multiple attachments in the workflow container.
Kindly help me, how to store and also, how to retrieve those attachments form worklfow.
I am using custom workflow.
Thanks in advance......
Best Regards,
Chandran SHi Jubish/Venkat
1. I iterated this fucntion moudule to store the multiple attachments to the workflow
SAP_WAPI_ATTACHMENT_ADD
2. Call this FM to get the attachemnts form the workflow (pass workitem Item id which is used for storing the attchments). SAP_WAPI_GET_ATTACHMENTS
from above you will get objkey for each attachment as output in table.
3. Pass the objkey to this FM to get the contents
SO_DOCUMENT_READ_API1'. this will retrun the content of the attachment either in object_content, contents_hex.
4. Pass the Obtained content to SCMS_BINARY_TO_XSTRING to get the disired format.
Best Regards,
Chandran S -
How to store / retrieve attachments?
Hi Experts,
I am sending message attachments to XI using ABAP Proxy program. The message itself has a number which identifies the attachment.
My requirement is to store the attachment in some format in ABAP table. The is required because there is a webapplication which will send a SOAP request to XI to fetch the attachemnt. The request will have the attachment identification number and the response should have the attachment itself in SOAP body.
Could you please tell me how to store the attachment in XI and how to retrieve the same using a webservice call?
Thanks,
ShobhitHi,
Refer these articles
http://help.sap.com/saphelp_nw04/helpdata/en/a7/3b2a2d45a34a23b75e3b18745c63bc/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/de/705c3c3806af06e10000000a11402f/content.htm
Refer these blogs
ABAP POP3 Email Client Using an RFC enabled PHP client proxy
XI: Reliable Messaging EOIO in ABAP Proxies
BSP a Developer's Journal Part XIV - Consuming WebServices with ABAP
Regards,
Suryanarayana -
Where does Messages store attachments on the iPad?
Where does Messages store attachments on the iPad?
some photos are quite large, so it would be good to know where they go, and how to manage the app.... ;)Managing memory usage is not possible because the user does not have access to the file structure (unless you have jail broken your iPad that is).
-
How to store data (in tdm files)
I'm looking for advice on how to store data in tdm/tdx files.
The main challenge is like this: At regular time intervals there is new data available (say every 10 minutes there are 10 minutes of new data available). All data is time based. So every ten minutes I may create a new tdm/tdx file containing this data segment. However, when i want to analyze the data i dont necessarily want to view 10 minutes of data from all channels, but maybe 20 hours of data from one particular channel.
The way I've achieved this so far is to manually load each 10 minute segment of this particular channel and then add these parts together. This is both time consuming and cumbersome. Is there a better way to do this that I've simply not discovered yet? Is there a better way to store data to simplify this process?
One solution is of course to save data from several 10-minute frames in one file, but seeing as there is a never ending supply of data i cant simply save all data in one giant file, it has to be split up at some point, and the problem will still remain.
One factor to have in mind here is that this is rather large amounts of data (maybe 10GB each day), so the option to simply load all the data into memory goes out the window rather quickly.
Feel free to ask if I've not made myself very clearHi salte,
If your test ever ended, and if you had LabVIEW 8.20 or higher, I would recommend using a TDMS file, which handles data appeands flawlessly. DIAdem 10.1 now also does data reduction and index windowing during file loading for TDM / TDMS / DataPlugin files, so that you could easily load out only the part of the file you wanted to look at. But since you describe your data acquisition as never stopping and amassing 10 GB per day, I agree that it would be impractical to use only 1 data file. So we are stuck with some number of files which each contain a part of your measurement. This approach can have advantages, since you can save operational properties for each "buffer" such as average value, dominant frequency, ambient room temperature, etc., and later on you can use the DataFinder to query out only the data buffers which meet specific conditions based on these properties. The problem remains to load and assemble data based on multiple files. This is an old problem in DIAdem, and one for which I have an efficient and I hope satisfactory workaround application. It does what you describe already doing in the minimum amount of time and with the minimum amount of user interaction, and it can be highly parametrized to suit your particular situation. The ideal way to start the application would be as part of a ResultsList custom menu. This would enable you to query out the buffers you wanted, highlight those rows in the ResultsList, right-click and choose your custom menu, and WHAM! the selected buffers for your queried channel(s) are automatically appended together in the DataPortal. Launching from a ResultsList custom menu would mean that you could skip the file dialog and just read out the data sources directly from the ResultsList selection.
Let me know what you think,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
Attachments:
Importing Data from Multiple DataPlugin Files.zip 198 KB -
How to store documents in my ipad
I received few word documents via gmail.
How to save those documents to my ipad?
and am unable to attach documnet to my mail..
Kindly advice.If you want to store word documents (or any other file/document) on the iPad then you need one or more apps on the iPad that supports word documents - unlike a 'normal' computer the iPad doesn't have a file system, and everything on it has to be associated with an app.
If you want to be able to edit (and create) word documents then the options include Apple's Pages app and from third-parties apps such as Documents To Go and QuickOffice Pro HD. If you just want to store them then there are apps such as GoodReader. You can use the Mail app's 'open in' function to copy/store attachments into other apps.
To then attach a document to an email you need to start in the app that contains the document and use that app's functionality (if it has it) to select and attach the document to an email. -
How to store 2C array to a singl binary file
Hi
I have to store multiple waveforms output that is each 1D array to a single binary file. how do i do this.
i can store 1D array to binary file and retrieve it by reading the binary file and plotting the waveform. but i am not able to store 2D array to the single file. how do store many 1D array in one binary file,
Thank you. Hema(We would also need to know your LabVIEW version. If you have a very old version, things would be quite different.)
As Smercurio_fc already mentioned, the option to "prepend array size" would make things much easier here, because then you would read it as a single 2D array.
Here's how that would look like. This is probably the recommended solution, just for simplicity reasons.
Not prepending the size is more useful if you write the data in increments, but later want to read it as one.
Message Edited by altenbach on 11-15-2008 09:02 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
SaveRestore2D.png 21 KB -
How to store notes using GOS functionality
hi expert
urgent things
can u help me in this issue how to store note or text in repository using GOS generic object services ???
as soon as possible .
thank youHello,
We cannot move the notes, stored through GOS, to content server as the size of the notes is not huge.
Only the PC attachments through GOS can be directed to content server.
Refer to the note 530792 for more details.
Cheers
Amit -
How to store numbers in a stack....
hello guys...i ve got the following assignment:
Write a Java program that reads and evaluates a fully parenthesised arithmetic expression. The
purpose of this program is to illustrate a fundamental use of stacks. Implement the stack using
Linked Lists as explained in your notes.
For e.g if a user enters the expression: (((6 + 9) / 3) * (6 � 4))
The result should be 10.
Your program should be properly documented and well structured. Specifications should be
clearly written in your logbook for all the methods, constructors, and classes that you implement
in the following format:
Class / Method/ Constructor name explaining what it does
Parameters
Preconditions
Postconditions
Throws
Now, i ve come up with the following code:
import java.util.EmptyStackException;
class StackNode {
private static Object data;
private StackNode link;
private static StackNode head;
private int totalnodes;
// the constructors
public StackNode(Object obj, StackNode lk)
data = obj;
link = lk;
public StackNode()
head = null;
totalnodes = 0;
// the push method
public void push(Object obj)
head = new StackNode(obj, head);
totalnodes++;
// the pop method
public Object pop()
Object answer;
if(head == null)
throw new EmptyStackException();
answer = head.getData();
head = head.getLink();
totalnodes--;
return answer;
// the isEmpty method
public boolean isEmpty()
return (head == null);
// get data
public Object getData()
return data;
// get link
public StackNode getLink()
return link;
// size or length method
public int size()
return totalnodes;
public static void main (String args [])
int i;
StackNode number = new StackNode();
StackNode operator = new StackNode();
head = new StackNode(data, head);
number.push(new Integer(9));
number.push(new Integer(6));
operator.push(new Character('+'));
and i dont know how to store numbers into the stack and how to use the operations such as addition substraction division and multiply...
any ideas how to do that??
cheers....This doesn't use a stack but the concept is the same:
import java.util.*;
public class formula {
public int aValue = 1;
public int bValue = 2;
public int cValue = 3;
public formula() {
//StringTokenizer st = new StringTokenizer("a + b/c", " abc()+-*/", true);
//while (st.hasMoreTokens()) { System.out.println(st.nextToken()); }
StringTokenizer st2 = new StringTokenizer("a + (c - b) + (b * c)", " abc()+-*/", true);
int operand1 = 0;
int operand2 = 0;
int operator = 0;
//flag: first operand has a value
boolean firstOperandFull = false;
//flag: second operand has a value
boolean secondOperandFull = false;
//flag: tokens are between parens
boolean inParens = false;
Vector inParensVector = null;
MAINLOOP:
while (st2.hasMoreTokens()) {
String x = st2.nextToken();
//if token is a blank skip it.
if (x.equals(" ")) { continue MAINLOOP; }
System.out.println(x);
//if token is open parens set flag and skip to next token
if (x.equals("(")) { inParens = true; inParensVector = new Vector(); continue MAINLOOP; }
//if tokn is close parens, retrieve the value from between the parens and reset flag.
if (x.equals(")")) { if (! firstOperandFull) { operand1 = doInParens(inParensVector); firstOperandFull = true; }
else { operand2 = doInParens(inParensVector); secondOperandFull = true; }
inParensVector = null; inParens = false; }
//if token is open parens store all tokens until close else process the token
if (inParens) { inParensVector.add(x); }
else {
//if token is a variable put correct value in operand
if (x.equals("a")) { if (! firstOperandFull) { operand1 = aValue; firstOperandFull = true; }
else { operand2 = aValue; secondOperandFull = true; } }
if (x.equals("b")) { if (! firstOperandFull) { operand1 = bValue; firstOperandFull = true; }
else { operand2 = bValue; secondOperandFull = true; } }
if (x.equals("c")) { if (! firstOperandFull) { operand1 = cValue; firstOperandFull = true; }
else { operand2 = cValue; secondOperandFull = true; } }
//if token is a operator store the operation
if (x.equals("+")) { if (firstOperandFull) { operator = 1; } }
if (x.equals("-")) { if (firstOperandFull) { operator = 2; } }
if (x.equals("*")) { if (firstOperandFull) { operator = 3; } }
if (x.equals("/")) { if (firstOperandFull) { operator = 4; } }
System.out.println("operand1 = " + operand1 + " operand2 = " + operand2 + " operator = " + operator);
//if second operand has a value perform the operation.
if (secondOperandFull) {
switch (operator) {
case 1 : operand1 = add(operand1, operand2); secondOperandFull = false; break;
case 2 : operand1 = subtract(operand1, operand2); secondOperandFull = false; break;
case 3 : operand1 = multiply(operand1, operand2); secondOperandFull = false; break;
case 4 : operand1 = divide(operand1, operand2); secondOperandFull = false; break;
}//end switch
} //end if
} //End inParens else
} //End while
System.out.println("answer = " + operand1);
public static void main(String[] args) { //formula f = new formula();
Vector v = new Vector();
StringTokenizer st = new StringTokenizer(",Greg,,Paul,,", ",", true);
String token = null;
String lastToken = " ";
boolean firstToken = true;
while (st.hasMoreTokens()) {
token = st.nextToken();
if (firstToken) { if (token.equals(",")) { v.add("X"); }
firstToken = false; }
if (! token.equals(",")) { v.add(token); }
else { if (lastToken.equals(",")) { v.add("X"); } }
lastToken = token;
} //End While
if (token.equals(",")) { v.add("X"); }
Enumeration tokens = v.elements();
while (tokens.hasMoreElements()) {
System.out.println((String)tokens.nextElement()); }
} //End Main
public int add(int operand1, int operand2) { return operand1 + operand2; }
public int subtract(int operand1, int operand2) { return operand1 - operand2; }
public int divide(int operand1, int operand2) { return operand1 / operand2; }
public int multiply(int operand1, int operand2) { return operand1 * operand2; }
public int doInParens(Vector inParensVector) {
int operand1 = 0;
int operand2 = 0;
int operator = 0;
boolean firstOperandFull = false;
boolean secondOperandFull = false;
Enumeration tokens = inParensVector.elements();
INPARENSLOOP:
while (tokens.hasMoreElements()) {
String x = (String)tokens.nextElement();
//if token is a blank skip it.
if (x.equals(" ")) { continue INPARENSLOOP; }
System.out.println("inparens : " + x);
//if token is a variable put correct value in operand
if (x.equals("a")) { if (! firstOperandFull) { operand1 = aValue; firstOperandFull = true; }
else { operand2 = aValue; secondOperandFull = true; } }
if (x.equals("b")) { if (! firstOperandFull) { operand1 = bValue; firstOperandFull = true; }
else { operand2 = bValue; secondOperandFull = true; } }
if (x.equals("c")) { if (! firstOperandFull) { operand1 = cValue; firstOperandFull = true; }
else { operand2 = cValue; secondOperandFull = true; } }
//if token is a operator store the operation
if (x.equals("+")) { if (firstOperandFull) { operator = 1; } }
if (x.equals("-")) { if (firstOperandFull) { operator = 2; } }
if (x.equals("*")) { if (firstOperandFull) { operator = 3; } }
if (x.equals("/")) { if (firstOperandFull) { operator = 4; } }
System.out.println("Inparens : operand1 = " + operand1 + " operand2 = " + operand2 + " operator = " + operator);
if (secondOperandFull) {
switch (operator) {
case 1 : operand1 = add(operand1, operand2); secondOperandFull = false; break;
case 2 : operand1 = subtract(operand1, operand2); secondOperandFull = false; break;
case 3 : operand1 = multiply(operand1, operand2); secondOperandFull = false; break;
case 4 : operand1 = divide(operand1, operand2); secondOperandFull = false; break;
}//end switch
} //end if
} //End while
System.out.println("Inparens return = " + operand1);
return operand1;
}//End doInParens
}//End Class -
How to store multiple files from SAp in to Application server?
Hi Guys,
Can anybody tell me how to store multiple files from SAP into Application server.in my application i have to get the data from SAP tables BSEG , BKPF , BSAK and BSIK that to daily i have to do.
Any Logic or Code for how to do is welcomed.
plz help me urgently.
Thanks,
GopiHi,
directories creates basis. If you have task to store data in application server you already should have information into which folder you have to do it. If you don't have this information because it is just for example training for next task then you can use your personal folder into which you have access. To get list of all available folders please look at attached code and form get_directories (you get the list of folders you see in transaction AL11). But don't forget: If you are using open dataset you have to have rights to access application folder!
Here you are code which I use to upload text files from local disc into application folder
Regards,
Karol
*& Report FILE_PC_TO_SAP
REPORT FILE_PC_TO_SAP.
DATA: BEGIN OF searchpoints OCCURS 100,
DIRNAME(200) TYPE c, " name of directory.
sp_name(100) TYPE c," name of entry. (may end with *)
END OF searchpoints.
DATA: BEGIN OF isearchpoints OCCURS 10,
dirname(75) TYPE c, " name of directory.
aliass(75) TYPE c, " alias for directory.
svrname(75) TYPE c, " svr where directory is availabl
sp_name(75) TYPE c, " name of entry. (may end with *)
sp_cs(10) TYPE c, " ContainsString pattern for name
END OF isearchpoints.
data: l_file type filetable.
data: l_rc type i.
data: itab type TABLE OF string.
data: g_tmp_file_path type rlgrap-filename.
data: wa_itab type string.
data: h_destin(100) type c.
data: dat type string.
INITIALIZATION.
perform get_directories.
START-OF-SELECTION.
parameters: in_file type string OBLIGATORY LOWER CASE.
parameters: destin(100) type c OBLIGATORY LOWER CASE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = in_file
"FILETYPE = 'BIN'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF sy-SUBRC <> 0.
write: / 'Error during loading input file!'.
ENDIF.
if h_destin is INITIAL.
h_destin = in_file.
endif.
CONCATENATE destin h_destin into dat SEPARATED BY '/'.
*TRANSLATE dat TO UPPER CASE.
OPEN DATASET dat FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-SUBRC = 0.
loop at itab into wa_itab.
TRANSFER: wa_itab TO dat.
endloop.
CLOSE DATASET dat.
write: / 'File uploaded!'.
ELSE.
write: / 'Not possible to open dataset'.
ENDIF.
at selection-screen on value-request for in_file.
perform select_input_file_name.
loop at l_file into g_tmp_file_path.
move g_tmp_file_path to in_file.
h_destin = ''.
SPLIT g_tmp_file_path at '\' into table itab.
loop at itab into g_tmp_file_path.
h_destin = g_tmp_file_path.
endloop.
endloop.
at selection-screen on value-request for destin.
DATA: lt_dfies TYPE TABLE OF dfies.
DATA: lwa_dfies TYPE dfies.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = '/BI0/PCO_AREA'
lfieldname = 'CO_AREA'
IMPORTING
dfies_wa = lwa_dfies.
lwa_dfies-tabname = 'searchpoints'.
lwa_dfies-REPTEXT = 'Destination directory'.
lwa_dfies-LENG = 100.
lwa_dfies-INTLEN = 100.
lwa_dfies-OUTPUTLEN = 100.
lwa_dfies-fieldname = 'SP_NAME'.
APPEND lwa_dfies TO lt_dfies.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'SP_NAME'
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'destin'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = searchpoints
FIELD_TAB = lt_dfies
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
*& Form select_input_file_name
* text
form select_input_file_name.
* call function 'F4_FILENAME'
* exporting
* program_name = sy-repid
* dynpro_number = sy-dynnr
* field_name = 'PATH'
* importing
* file_name = g_tmp_file_path.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Please choose a file'
"default_extension = '*.TXT'
"default_filename = 'C:\*.txt'
initial_directory = 'C:\'
file_filter = '*.*'
CHANGING
FILE_TABLE = l_file
RC = l_RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. "select_input_file_name
*& Form WRITE_DB_HOME
* Write DB home directory
* no parameters
FORM write_db_home.
CASE sy-dbsys(3).
WHEN 'ORA'.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_ORAHOME'
ID 'VALUE' FIELD searchpoints-dirname.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_ORAHOME', 30 searchpoints-dirname.
MOVE: 'DIR_ORAHOME' TO searchpoints-sp_name.
APPEND searchpoints.
*--- C5056155 End of ALV -------------------------------*
WHEN 'ADA'.
CALL 'C_GETENV' ID 'NAME' FIELD 'DBROOT'
ID 'VALUE' FIELD searchpoints-dirname.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_ADA_DBROOT', 30 searchpoints-dirname.
MOVE: 'DIR_ADA_DBROOT' TO searchpoints-sp_name.
APPEND searchpoints.
*--- C5056155 End of ALV -------------------------------*
WHEN 'INF'.
CALL 'C_GETENV' ID 'NAME' FIELD 'INFORMIXDIR'
ID 'VALUE' FIELD searchpoints-dirname.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_INF_INFORMIXDIR', 30 searchpoints-dirname.
MOVE: 'DIR_INF_INFORMIXDIR' TO searchpoints-sp_name.
APPEND searchpoints..
*--- C5056155 End of ALV -------------------------------*
WHEN 'DB6'.
CALL 'C_GETENV' ID 'NAME' FIELD 'INSTHOME'
ID 'VALUE' FIELD searchpoints-dirname.
IF sy-subrc = 0.
*--- C5056155 Start of ALV -------------------------------*
* PERFORM flip_flop(rsora000) USING cflag.
* WRITE: / 'DIR_DB2_HOME', 30 searchpoints-dirname.
MOVE: 'DIR_DB2_HOME' TO searchpoints-sp_name.
APPEND searchpoints.
*--- C5056155 End of ALV -------------------------------*
ELSE.
EXIT.
ENDIF.
WHEN OTHERS.
EXIT.
ENDCASE.
ENDFORM. " WRITE_DB_HOME
FORM get_directories.
* get the name and aliases of ALL userdefined directories
SELECT * FROM user_dir INTO isearchpoints
WHERE svrname = sy-uname.
MOVE isearchpoints-dirname to searchpoints-dirname.
MOVE isearchpoints-aliass to searchpoints-sp_name.
APPEND searchpoints.
ENDSELECT.
SELECT * FROM user_dir INTO isearchpoints
WHERE svrname = 'all'.
MOVE isearchpoints-dirname to searchpoints-dirname.
MOVE isearchpoints-aliass to searchpoints-sp_name.
APPEND searchpoints.
ENDSELECT.
* Get DB home
IF sy-dbsys(3) = 'ADA'.
PERFORM write_db_home.
ENDIF.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_ATRA'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_ATRA' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_BINARY'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_BINARY' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory $DIR_CCMS
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_CCMS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_CCMS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_CT_LOGGING'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_CT_LOGGING' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_CT_RUN'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_CT_RUN' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_DATA'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_DATA' TO searchpoints-sp_name.
APPEND searchpoints.
* Get DB home
IF sy-dbsys(3) = 'DB6'.
PERFORM write_db_home.
ENDIF.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_DBMS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_DBMS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_EXECUTABLE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_EXECUTABLE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_EXE_ROOT'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_EXE_ROOT' TO searchpoints-sp_name.
APPEND searchpoints.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GEN'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GEN' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GEN_ROOT'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GEN_ROOT' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GLOBAL'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GLOBAL' TO searchpoints-sp_name.
APPEND searchpoints.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GRAPH_EXE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GRAPH_EXE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_GRAPH_LIB'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_GRAPH_LIB' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_HOME'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_HOME' TO searchpoints-sp_name.
APPEND searchpoints.
* Get DB home
IF sy-dbsys(3) = 'INF'.
PERFORM write_db_home.
ENDIF.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_INSTALL'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_INSTALL' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_INSTANCE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_INSTANCE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_LIBRARY'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_LIBRARY' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_LOGGING'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_LOGGING' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the files written by the memory inspector
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_MEMORY_INSPECTOR'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_MEMORY_INSPECTOR' TO searchpoints-sp_name.
APPEND searchpoints.
* Get DB home
IF sy-dbsys(3) = 'ORA'.
PERFORM write_db_home.
ENDIF.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PAGING'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PAGING' TO searchpoints-sp_name.
APPEND searchpoints.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PUT'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PUT' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PERF'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PERF' TO searchpoints-sp_name.
APPEND searchpoints.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PROFILE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PROFILE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_PROTOKOLLS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_PROTOKOLLS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_REORG'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_REORG' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_ROLL'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_ROLL' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_RSYN'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_RSYN' TO searchpoints-sp_name.
APPEND searchpoints.
* calculate directory for saphostagent (no sapparam available...)
IF ( sy-opsys(3) = 'WIN' ) OR ( sy-opsys(3) = 'Win' ).
DATA: windir_path(64), programfiles_path(64).
* hoping that ProgramFiles is set in service user environment
CALL 'C_GETENV' ID 'NAME' FIELD 'ProgramFiles'
ID 'VALUE' FIELD programfiles_path.
IF programfiles_path IS INITIAL.
* %ProgramFiles% not available. guess from windir
CALL 'C_GETENV' ID 'NAME' FIELD 'windir'
ID 'VALUE' FIELD windir_path.
* e.g. S:\WINDOWS ==> S:\Program Files
CONCATENATE windir_path(3) 'Program Files' INTO programfiles_path.
ENDIF.
CONCATENATE programfiles_path '\SAP\hostctrl'
INTO searchpoints-dirname.
ELSE.
* on UNIX, the path is hard coded
searchpoints-dirname = '/usr/sap/hostctrl'.
ENDIF.
MOVE: 'DIR_SAPHOSTAGENT' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SAPUSERS'
ID 'VALUE' FIELD searchpoints-dirname.
IF searchpoints-dirname = '.'.
IF sy-opsys = 'Windows NT'.
searchpoints-dirname = '.\'.
ELSE.
searchpoints-dirname = './'.
ENDIF.
ENDIF.
MOVE: 'DIR_SAPUSERS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SETUPS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_SETUPS' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SORTTMP'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_SORTTMP' TO searchpoints-sp_name.
APPEND searchpoints.
*get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_SOURCE'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_SOURCE' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TEMP'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TEMP' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRANS'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TRANS' TO searchpoints-sp_name.
APPEND searchpoints.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRFILES'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TRFILES' TO searchpoints-sp_name.
APPEND searchpoints.
* get name of directory with the error files
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'DIR_TRSUB'
ID 'VALUE' FIELD searchpoints-dirname.
MOVE: 'DIR_TRSUB' TO searchpoints-sp_name.
APPEND searchpoints.
* get the name of the current server.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'rdisp/myname'
ID 'VALUE' FIELD searchpoints-dirname.
data: h_ind type i.
LOOP AT searchpoints.
h_ind = sy-tabix.
IF searchpoints-sp_name IS INITIAL.
DELETE searchpoints INDEX h_ind.
ENDIF.
ENDLOOP.
ENDFORM. -
How to store España in database (in a column of a table)
Could you please tell me how to store España in database (in a column of a table).
regardsGenerally speaking you'll need a character set that can support the characters you require.
Here is a link to the supported character sets in 10.2.x.x:
[Character Sets|http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/applocaledata.htm#i635016] -
How to store this value in date variable?
Hi sir,
i am having one query which is
select to_char(date '1900-01-01' + 1439/(24*60),'DD/MM/YYYY HH24:MI:ss')from dual;
when i am running this query i am getting this value: 01/01/1900 23:59:00
and this value i am inserting in one variable which has date datatype.
here i am storing like this:
v_nshiftmax := to_char(date '1900-01-01' + 1439/(24*60),'DD/MM/YYYY HH24:MI:SS');
while storing getting error: not a valid month
how to store it in this variable?
thanks964430 wrote:
why using TO_DATE (), to improve performance avoid function calling if you can do without it, just use v_nshiftmax := date '1900-01-01' + 1439/(24*60); remove TO_CHAR() function only, as you already converted it to date.Please prove to us that TO_DATE(...) is slower that using DATE '...'
Both are internal functions that take a string and turn it into a date. -
How to store an image into MySQL db using BlazeDS and Hibernate?
Hi!
I am using Flash Builder 4.6, BlazeDS, and Hibernate. How to store a webcam snapshot into the MySql Database. I stored Form Items by using RemoteObject into the database. But I failed to store webcam snapshot. I captured that image on Panel component.I converted that image to ByteArray. Now I want to save that image into the database. Please help me in this regard.
thanks in advance.
Here the Code:
VisitorEntryForm.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:vo="com.visitor.vo.*"
width="600"
height="300"
defaultButton="{submitButton}"
showCloseButton="true"
creationComplete="creationCompleteHandler();"
close="PopUpManager.removePopUp(this);"
title="Visitor Entry Form" xmlns:text="flash.text.*">
<mx:RemoteObject id="saveService" destination="visitorService" result="handleSaveResult(event)" fault="handleFault(event)" showBusyCursor="true" />
<vo:Visitor id="visitor"
vType="{vTypeField.text}"
vPurpose="{vPurposeField.text}"
vName="{vNameField.text}"
vAddress="{vAddressField.text}"
cPerson="{cPersonField.text}"
cAddress="{cAddressField.text}"
/>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import flash.media.Camera;
import com.visitor.vo.WebCam;
import com.visitor.vo.Base64;
import mx.core.UIComponent;
import mx.graphics.codec.JPEGEncoder;
import mx.controls.Alert;
import mx.containers.Canvas;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ValidationResultEvent;
import mx.validators.Validator;
[Bindable]
private var webCam: com.visitor.vo.WebCam;
[Bindable]
private var message:String;
[Bindable]
private var formIsValid:Boolean = false;
[Bindable]
public var formIsEmpty:Boolean;
private var focussedFormControl:DisplayObject;
private function handleSaveResult(ev:ResultEvent):void {
clearFormHandler();
validateForm(ev);
Alert.show("Visitor successfully created/updated.", "Information", Alert.OK, null, null, null, Alert.OK);
// Reload the list.
parentApplication.listConsultants.loaderService.getConsultants();
PopUpManager.removePopUp(this);
private function handleFault(ev:FaultEvent):void {
message = "Error: " + ev.fault.faultCode + " \n "
+ "Detail: " + ev.fault.faultDetail + " \n "
+ "Message: " + ev.fault.faultString;
public function saveVisitor():void {
saveService.addUpdateVisitor(visitor);
private function creationCompleteHandler():void {
init();
PopUpManager.centerPopUp(this);
resetFocus();
private function resetFocus():void {
focusManager.setFocus(vTypeField);
public function validateForm(event:Event):void {
focussedFormControl = event.target as DisplayObject;
formIsValid = true;
// Check if form is empty
formIsEmpty = (vTypeField.text == "" && vPurposeField.text == "" && vNameField.text == "" && vAddressField.text == "" && cPersonField.text == "" && cAddressField.text == "");
validate(vTypeValidator);
validate(vPurposeValidator);
validate(vNameValidator);
validate(vAddressValidator);
validate(cPersonValidator);
validate(cAddressValidator);
private function validate(validator:Validator):Boolean {
var validatorSource:DisplayObject = validator.source as DisplayObject;
var suppressEvents:Boolean = (validatorSource != focussedFormControl);
var event:ValidationResultEvent = validator.validate(null, suppressEvents);
var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID);
formIsValid = formIsValid && currentControlIsValid;
return currentControlIsValid;
private function clearFormHandler():void {
// Clear all input fields.
vTypeField.text = "";
vPurposeField.text = "";
vNameField.text = "";
vAddressField.text = "";
cPersonField.text = "";
cAddressField.text = "";
message = "";
// Clear validation error messages.
vTypeField.errorString = "";
vPurposeField.errorString = "";
vNameField.errorString = "";
vAddressField.errorString = "";
cPersonField.errorString = "";
cAddressField.errorString = "";
formIsEmpty = true;
formIsValid = false;
resetFocus();
private function init():void {
webCam = new WebCam(97,97);
var ref:UIComponent = new UIComponent();
preview.removeAllChildren();
preview.addChild(ref);
ref.addChild(webCam);
private function takeSnapshot():void {
imageViewer.visible = true;
imageViewer.width = preview.width;
imageViewer.height = preview.height;
var uiComponent : UIComponent = new UIComponent();
uiComponent.width = webCam.width;
uiComponent.height = webCam.height;
var photoData:Bitmap = webCam.getSnapshot();
var photoBitmap:BitmapData = photoData.bitmapData;
uiComponent.addChild(photoData);
imageViewer.removeAllChildren();
imageViewer.addChild(uiComponent);
private function uploadSnapshot():void
if (imageViewer.getChildren().length > 0)
var uic:UIComponent = imageViewer.getChildAt(0) as UIComponent;
var bitmap:Bitmap = uic.getChildAt(0) as Bitmap;
var jpgEncoder:JPEGEncoder = new JPEGEncoder(75);
var jpgBytes:ByteArray = jpgEncoder.encode(bitmap.bitmapData);
private function deleteSnapshot():void
imageViewer.removeAllChildren();
]]>
</mx:Script>
<mx:StringValidator id="vTypeValidator" source="{vTypeField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="vPurposeValidator" source="{vPurposeField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="vNameValidator" source="{vNameField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="vAddressValidator" source="{vAddressField}" property="text" minLength="5" required="true" />
<mx:StringValidator id="cPersonValidator" source="{cPersonField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="cAddressValidator" source="{cAddressField}" property="text" minLength="5" required="true" />
<mx:Grid width="575" height="211">
<mx:GridRow width="575" height="211">
<mx:GridItem width="301" height="235">
<mx:Form width="301" height="208">
<mx:FormItem label="Visitor's Type">
<mx:ComboBox id="vTypeField" text="{visitor.vType}" change="validateForm(event);" editable="true">
<mx:Array>
<mx:String></mx:String>
<mx:String>Contractor</mx:String>
<mx:String>Supplier</mx:String>
<mx:String>Transporter</mx:String>
<mx:String>Plant</mx:String>
<mx:String>Non-Plant</mx:String>
</mx:Array>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Visit Purpose">
<mx:ComboBox id="vPurposeField" text="{visitor.vPurpose}" change="validateForm(event);" editable="true">
<mx:Array>
<mx:String></mx:String>
<mx:String>Official</mx:String>
<mx:String>Personal</mx:String>
</mx:Array>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Visitor's Name">
<mx:TextInput id="vNameField" text="{visitor.vName}" change="validateForm(event);"/>
</mx:FormItem>
<mx:FormItem label="Address">
<mx:TextInput id="vAddressField" text="{visitor.vAddress}" change="validateForm(event);"/>
</mx:FormItem>
<mx:FormItem label="Contact Person">
<mx:TextInput id="cPersonField" text="{visitor.cPerson}" change="validateForm(event);"/>
</mx:FormItem>
<mx:FormItem label="Address">
<mx:TextInput id="cAddressField" text="{visitor.cAddress}" change="validateForm(event);"/>
</mx:FormItem>
</mx:Form>
</mx:GridItem>
<mx:GridItem width="264" height="193">
<mx:Grid width="241" height="206">
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<mx:Panel width="100" height="132" title="Snap" id="preview" layout="absolute"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<mx:Panel width="100" height="132" title="Preview" id="imageViewer" layout="absolute"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="27" >
<mx:GridItem width="100%" height="100%" horizontalAlign="center">
<mx:Button id="snapshot" x="2" width="106" height="27" label="Snap"
click="takeSnapshot();"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%" horizontalAlign="center">
<mx:Button id="deleteButton" x="1" width="106" height="27" label="Delete"
click="deleteSnapshot();"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
<mx:ControlBar height="40" horizontalAlign="center">
<mx:Button label="Save Visitor" id="submitButton" enabled="{formIsValid}" click="saveVisitor();" />
<mx:Button label="Clear form" enabled="{!formIsEmpty}" click="clearFormHandler();" />
<mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
<mx:Label width="211" id="state"/>
</mx:ControlBar>
<mx:Text text="{message}" fontWeight="bold" width="300"/>
</mx:TitleWindow>
ListVisitors.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:view="com.visitor.view.*"
width="100%"
height="100%"
title="Visitor Management System - Found {visitorRecords} visitors."
creationComplete="loadVisitors();">
<mx:RemoteObject id="loaderService" destination="visitorService" result="handleLoadResult(event)" fault="handleFault(event)" showBusyCursor="true" />
<mx:RemoteObject id="deleteService" destination="visitorService" result="handleDeleteResult(event)" fault="handleFault(event)" showBusyCursor="true" />
<mx:Script>
<![CDATA[
import com.visitor.vo.Visitor;
import mx.controls.Alert;
import mx.managers.PopUpManager;
import mx.containers.TitleWindow;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
[Bindable]
private var message:String;
[Bindable]
private var visitors:ArrayCollection = new ArrayCollection();
[Bindable]
private var visitorRecords:int = 0;
public function loadVisitors():void {
loaderService.getVisitors();
private function deleteVisitor():void {
if(dataGrid.selectedItem != null) {
var selectedItem:Visitor = dataGrid.selectedItem as Visitor;
deleteService.deleteVisitor(selectedItem.visitorId);
private function createVisitor():void {
var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
titleWindow.setStyle("borderAlpha", 0.9);
titleWindow.formIsEmpty = true;
private function updateVisitor():void {
var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
titleWindow.setStyle("borderAlpha", 0.9);
titleWindow.visitor = dataGrid.selectedItem as Visitor;
titleWindow.formIsEmpty = false;
private function handleLoadResult(ev:ResultEvent):void {
visitors = ev.result as ArrayCollection;
visitorRecords = visitors.length;
private function handleDeleteResult(ev:ResultEvent):void {
Alert.show("The visitor has been deleted.", "Information", Alert.OK, null, null, null, Alert.OK);
loadVisitors();
private function handleFault(ev:FaultEvent):void {
message = "Error: "
+ ev.fault.faultCode + " - "
+ ev.fault.faultDetail + " - "
+ ev.fault.faultString;
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<mx:Label text="{message}" fontWeight="bold" includeInLayout="false" />
<mx:DataGrid
id="dataGrid"
width="100%"
height="100%"
dataProvider="{visitors}"
doubleClickEnabled="true"
doubleClick="updateVisitor()" >
<mx:columns>
<mx:DataGridColumn dataField="visitorId" headerText="Visitor ID" width="100"/>
<mx:DataGridColumn dataField="vType" headerText="Visitor's Type" />
<mx:DataGridColumn dataField="vPurpose" headerText="Visit Purpose" />
<mx:DataGridColumn dataField="vName" headerText="Visitor's Name" />
<mx:DataGridColumn dataField="vAddress" headerText="Visitor's Address" />
<mx:DataGridColumn dataField="cPerson" headerText="Contact Person" />
<mx:DataGridColumn dataField="cAddress" headerText="Contact Address" />
<mx:DataGridColumn dataField="timeIn" headerText="Time-In" />
<mx:DataGridColumn dataField="timeOut" headerText="Time-Out" />
<mx:DataGridColumn dataField="vPhoto" headerText="Visitor's Photo" />
</mx:columns>
</mx:DataGrid>
<mx:ControlBar horizontalAlign="center">
<mx:Button label="Create Visitor" click="createVisitor()" toolTip="Create a new visitor and store it in the database." />
<mx:Button label="Update Visitor" click="updateVisitor()" enabled="{dataGrid.selectedItem}" toolTip="Update an existing database visitor." />
<mx:Button label="Delete Visitor" click="deleteVisitor()" enabled="{dataGrid.selectedItem}" toolTip="Delete the visitor from the database." />
<mx:Button label="Reload Data" click="loadVisitors()" toolTip="Reload the visitor list from the database." />
</mx:ControlBar>
</mx:VBox>
</mx:Panel>
Visitor.as
package com.visitor.vo
import mx.controls.Image;
import spark.primitives.BitmapImage;
[Bindable]
[RemoteClass(alias="com.visitor.Visitor")]
public class Visitor
public function Visitor()
public var visitorId:Number;
public var vType:String;
public var vPurpose:String;
public var vName:String;
public var vAddress:String;
public var cPerson:String;
public var cAddress:String;
public var timeIn:Date;
public var timeOut:Date;
public var vPhoto: Image;
Visitor.java
package com.visitor;
import java.sql.Blob;
import java.sql.Timestamp;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
@Entity
@Table(name = "visitors")
@NamedQueries( {
@NamedQuery(name = "visitors.findAll", query = "from Visitor"),
@NamedQuery(name = "visitors.byId", query = "select v from Visitor v where v.visitorId= :visitorId") })
public class Visitor {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "visitorId", nullable = false)
private Long visitorId;
@Basic
@Index(name = "vType_idx_1")
@Column(name = "vType", nullable = true, unique = false)
private String vType;
@Basic
@Column(name = "vPurpose", nullable = true, unique = false)
private String vPurpose;
@Basic
@Column(name = "vName", nullable = true, unique = false)
private String vName;
@Basic
@Column(name = "vAddress", nullable = true, unique = false)
private String vAddress;
@Basic
@Column(name = "cPerson", nullable = true, unique = false)
private String cPerson;
@Basic
@Column(name = "cAddress", nullable = true, unique = false)
private String cAddress;
@Basic
@Column(name = "timeIn", nullable = false, unique = false)
private Timestamp timeIn;
@Basic
@Column(name = "timeOut", nullable = true, unique = false)
private Timestamp timeOut;
@Basic
@Column(name = "vPhoto", nullable = true, unique = false)
private Blob vPhoto;
public Visitor() {
super();
public Long getVisitorId() {
return visitorId;
public void setVisitorId(Long visitorId) {
this.visitorId = visitorId;
public String getvType() {
return vType;
public void setvType(String vType) {
this.vType = vType;
public String getvPurpose() {
return vPurpose;
public void setvPurpose(String vPurpose) {
this.vPurpose = vPurpose;
public String getvName() {
return vName;
public void setvName(String vName) {
this.vName = vName;
public String getvAddress() {
return vAddress;
public void setvAddress(String vAddress) {
this.vAddress = vAddress;
public String getcPerson() {
return cPerson;
public void setcPerson(String cPerson) {
this.cPerson = cPerson;
public String getcAddress() {
return cAddress;
public void setcAddress(String cAddress) {
this.cAddress = cAddress;
public Timestamp getTimeIn() {
return timeIn;
public void setTimeIn(Timestamp timeIn) {
this.timeIn = timeIn;
public Timestamp getTimeOut() {
return timeOut;
public void setTimeOut(Timestamp timeOut) {
this.timeOut = timeOut;
public Blob getvPhoto() {
return vPhoto;
public void setvPhoto(Blob vPhoto) {
this.vPhoto = vPhoto;
VisitorService.java
package com.visitor;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.log4j.Logger;
public class VisitorService {
private static final String PERSISTENCE_UNIT = "visitor_db";
private static Logger logger = Logger.getLogger(VisitorService.class);
public VisitorService() {
super();
public List<Visitor> getvisitors() {
logger.debug("** getVisitors called...");
EntityManagerFactory entityManagerFactory = Persistence
.createEntityManagerFactory(PERSISTENCE_UNIT);
EntityManager em = entityManagerFactory.createEntityManager();
Query findAllQuery = em.createNamedQuery("visitors.findAll");
List<Visitor> visitors = findAllQuery.getResultList();
if (visitors != null)
logger.debug("** Found " + visitors.size() + " records:");
return visitors;
public void addUpdateVisitor(Visitor visitor) throws Exception {
logger.debug("** addUpdateVisitor called...");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory(PERSISTENCE_UNIT);
EntityManager em = emf.createEntityManager();
// When passing Boolean and Number values from the Flash client to a
// Java object, Java interprets null values as the default values for
// primitive types; for example, 0 for double, float, long, int, short,
// byte.
if (visitor.getVisitorId() == null || visitor.getVisitorId() == 0) {
// New consultant is created
visitor.setVisitorId(null);
visitor.setTimeIn(new Timestamp(new Date().getTime()));
} else {
visitor.setTimeOut(new Timestamp(new Date().getTime()));
// Existing consultant is updated - do nothing.
EntityTransaction tx = em.getTransaction();
tx.begin();
try {
em.merge(visitor);
tx.commit();
} catch (Exception e) {
logger.error("** Error: " + e.getMessage());
tx.rollback();
throw new Exception(e.getMessage());
} finally {
logger.info("** Closing Entity Manager.");
em.close();
public void deleteVisitor(Long visitorId) {
logger.debug("** deleteVisitor called...");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory(PERSISTENCE_UNIT);
EntityManager em = emf.createEntityManager();
Query q = em.createNamedQuery("visitors.byId");
q.setParameter("visitorId", visitorId);
Visitor visitor = (Visitor) q.getSingleResult();
if (visitor != null) {
EntityTransaction tx = em.getTransaction();
tx.begin();
try {
em.remove(visitor);
tx.commit();
} catch (Exception e) {
logger.error("** Error: " + e.getMessage());
tx.rollback();
} finally {
logger.info("** Closing Entity Manager.");
em.close();
remoting-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
</adapters>
<default-channels>
<channel ref="my-amf" />
</default-channels>
<!-- ADC Demo application -->
<destination id="visitorService">
<properties>
<source>com.visitor.VisitorService</source>
</properties>
</destination>
</service>Hi!
I am using Flash Builder 4.6, BlazeDS, and Hibernate. How to store a webcam snapshot into the MySql Database. I stored Form Items by using RemoteObject into the database. But I failed to store webcam snapshot. I captured that image on Panel component.I converted that image to ByteArray. Now I want to save that image into the database. Please help me in this regard.
thanks in advance.
Here the Code:
VisitorEntryForm.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:vo="com.visitor.vo.*"
width="600"
height="300"
defaultButton="{submitButton}"
showCloseButton="true"
creationComplete="creationCompleteHandler();"
close="PopUpManager.removePopUp(this);"
title="Visitor Entry Form" xmlns:text="flash.text.*">
<mx:RemoteObject id="saveService" destination="visitorService" result="handleSaveResult(event)" fault="handleFault(event)" showBusyCursor="true" />
<vo:Visitor id="visitor"
vType="{vTypeField.text}"
vPurpose="{vPurposeField.text}"
vName="{vNameField.text}"
vAddress="{vAddressField.text}"
cPerson="{cPersonField.text}"
cAddress="{cAddressField.text}"
/>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import flash.media.Camera;
import com.visitor.vo.WebCam;
import com.visitor.vo.Base64;
import mx.core.UIComponent;
import mx.graphics.codec.JPEGEncoder;
import mx.controls.Alert;
import mx.containers.Canvas;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ValidationResultEvent;
import mx.validators.Validator;
[Bindable]
private var webCam: com.visitor.vo.WebCam;
[Bindable]
private var message:String;
[Bindable]
private var formIsValid:Boolean = false;
[Bindable]
public var formIsEmpty:Boolean;
private var focussedFormControl:DisplayObject;
private function handleSaveResult(ev:ResultEvent):void {
clearFormHandler();
validateForm(ev);
Alert.show("Visitor successfully created/updated.", "Information", Alert.OK, null, null, null, Alert.OK);
// Reload the list.
parentApplication.listConsultants.loaderService.getConsultants();
PopUpManager.removePopUp(this);
private function handleFault(ev:FaultEvent):void {
message = "Error: " + ev.fault.faultCode + " \n "
+ "Detail: " + ev.fault.faultDetail + " \n "
+ "Message: " + ev.fault.faultString;
public function saveVisitor():void {
saveService.addUpdateVisitor(visitor);
private function creationCompleteHandler():void {
init();
PopUpManager.centerPopUp(this);
resetFocus();
private function resetFocus():void {
focusManager.setFocus(vTypeField);
public function validateForm(event:Event):void {
focussedFormControl = event.target as DisplayObject;
formIsValid = true;
// Check if form is empty
formIsEmpty = (vTypeField.text == "" && vPurposeField.text == "" && vNameField.text == "" && vAddressField.text == "" && cPersonField.text == "" && cAddressField.text == "");
validate(vTypeValidator);
validate(vPurposeValidator);
validate(vNameValidator);
validate(vAddressValidator);
validate(cPersonValidator);
validate(cAddressValidator);
private function validate(validator:Validator):Boolean {
var validatorSource:DisplayObject = validator.source as DisplayObject;
var suppressEvents:Boolean = (validatorSource != focussedFormControl);
var event:ValidationResultEvent = validator.validate(null, suppressEvents);
var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID);
formIsValid = formIsValid && currentControlIsValid;
return currentControlIsValid;
private function clearFormHandler():void {
// Clear all input fields.
vTypeField.text = "";
vPurposeField.text = "";
vNameField.text = "";
vAddressField.text = "";
cPersonField.text = "";
cAddressField.text = "";
message = "";
// Clear validation error messages.
vTypeField.errorString = "";
vPurposeField.errorString = "";
vNameField.errorString = "";
vAddressField.errorString = "";
cPersonField.errorString = "";
cAddressField.errorString = "";
formIsEmpty = true;
formIsValid = false;
resetFocus();
private function init():void {
webCam = new WebCam(97,97);
var ref:UIComponent = new UIComponent();
preview.removeAllChildren();
preview.addChild(ref);
ref.addChild(webCam);
private function takeSnapshot():void {
imageViewer.visible = true;
imageViewer.width = preview.width;
imageViewer.height = preview.height;
var uiComponent : UIComponent = new UIComponent();
uiComponent.width = webCam.width;
uiComponent.height = webCam.height;
var photoData:Bitmap = webCam.getSnapshot();
var photoBitmap:BitmapData = photoData.bitmapData;
uiComponent.addChild(photoData);
imageViewer.removeAllChildren();
imageViewer.addChild(uiComponent);
private function uploadSnapshot():void
if (imageViewer.getChildren().length > 0)
var uic:UIComponent = imageViewer.getChildAt(0) as UIComponent;
var bitmap:Bitmap = uic.getChildAt(0) as Bitmap;
var jpgEncoder:JPEGEncoder = new JPEGEncoder(75);
var jpgBytes:ByteArray = jpgEncoder.encode(bitmap.bitmapData);
private function deleteSnapshot():void
imageViewer.removeAllChildren();
]]>
</mx:Script>
<mx:StringValidator id="vTypeValidator" source="{vTypeField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="vPurposeValidator" source="{vPurposeField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="vNameValidator" source="{vNameField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="vAddressValidator" source="{vAddressField}" property="text" minLength="5" required="true" />
<mx:StringValidator id="cPersonValidator" source="{cPersonField}" property="text" minLength="2" required="true" />
<mx:StringValidator id="cAddressValidator" source="{cAddressField}" property="text" minLength="5" required="true" />
<mx:Grid width="575" height="211">
<mx:GridRow width="575" height="211">
<mx:GridItem width="301" height="235">
<mx:Form width="301" height="208">
<mx:FormItem label="Visitor's Type">
<mx:ComboBox id="vTypeField" text="{visitor.vType}" change="validateForm(event);" editable="true">
<mx:Array>
<mx:String></mx:String>
<mx:String>Contractor</mx:String>
<mx:String>Supplier</mx:String>
<mx:String>Transporter</mx:String>
<mx:String>Plant</mx:String>
<mx:String>Non-Plant</mx:String>
</mx:Array>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Visit Purpose">
<mx:ComboBox id="vPurposeField" text="{visitor.vPurpose}" change="validateForm(event);" editable="true">
<mx:Array>
<mx:String></mx:String>
<mx:String>Official</mx:String>
<mx:String>Personal</mx:String>
</mx:Array>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Visitor's Name">
<mx:TextInput id="vNameField" text="{visitor.vName}" change="validateForm(event);"/>
</mx:FormItem>
<mx:FormItem label="Address">
<mx:TextInput id="vAddressField" text="{visitor.vAddress}" change="validateForm(event);"/>
</mx:FormItem>
<mx:FormItem label="Contact Person">
<mx:TextInput id="cPersonField" text="{visitor.cPerson}" change="validateForm(event);"/>
</mx:FormItem>
<mx:FormItem label="Address">
<mx:TextInput id="cAddressField" text="{visitor.cAddress}" change="validateForm(event);"/>
</mx:FormItem>
</mx:Form>
</mx:GridItem>
<mx:GridItem width="264" height="193">
<mx:Grid width="241" height="206">
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<mx:Panel width="100" height="132" title="Snap" id="preview" layout="absolute"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<mx:Panel width="100" height="132" title="Preview" id="imageViewer" layout="absolute"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="27" >
<mx:GridItem width="100%" height="100%" horizontalAlign="center">
<mx:Button id="snapshot" x="2" width="106" height="27" label="Snap"
click="takeSnapshot();"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%" horizontalAlign="center">
<mx:Button id="deleteButton" x="1" width="106" height="27" label="Delete"
click="deleteSnapshot();"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
<mx:ControlBar height="40" horizontalAlign="center">
<mx:Button label="Save Visitor" id="submitButton" enabled="{formIsValid}" click="saveVisitor();" />
<mx:Button label="Clear form" enabled="{!formIsEmpty}" click="clearFormHandler();" />
<mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
<mx:Label width="211" id="state"/>
</mx:ControlBar>
<mx:Text text="{message}" fontWeight="bold" width="300"/>
</mx:TitleWindow>
ListVisitors.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:view="com.visitor.view.*"
width="100%"
height="100%"
title="Visitor Management System - Found {visitorRecords} visitors."
creationComplete="loadVisitors();">
<mx:RemoteObject id="loaderService" destination="visitorService" result="handleLoadResult(event)" fault="handleFault(event)" showBusyCursor="true" />
<mx:RemoteObject id="deleteService" destination="visitorService" result="handleDeleteResult(event)" fault="handleFault(event)" showBusyCursor="true" />
<mx:Script>
<![CDATA[
import com.visitor.vo.Visitor;
import mx.controls.Alert;
import mx.managers.PopUpManager;
import mx.containers.TitleWindow;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
[Bindable]
private var message:String;
[Bindable]
private var visitors:ArrayCollection = new ArrayCollection();
[Bindable]
private var visitorRecords:int = 0;
public function loadVisitors():void {
loaderService.getVisitors();
private function deleteVisitor():void {
if(dataGrid.selectedItem != null) {
var selectedItem:Visitor = dataGrid.selectedItem as Visitor;
deleteService.deleteVisitor(selectedItem.visitorId);
private function createVisitor():void {
var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
titleWindow.setStyle("borderAlpha", 0.9);
titleWindow.formIsEmpty = true;
private function updateVisitor():void {
var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
titleWindow.setStyle("borderAlpha", 0.9);
titleWindow.visitor = dataGrid.selectedItem as Visitor;
titleWindow.formIsEmpty = false;
private function handleLoadResult(ev:ResultEvent):void {
visitors = ev.result as ArrayCollection;
visitorRecords = visitors.length;
private function handleDeleteResult(ev:ResultEvent):void {
Alert.show("The visitor has been deleted.", "Information", Alert.OK, null, null, null, Alert.OK);
loadVisitors();
private function handleFault(ev:FaultEvent):void {
message = "Error: "
+ ev.fault.faultCode + " - "
+ ev.fault.faultDetail + " - "
+ ev.fault.faultString;
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<mx:Label text="{message}" fontWeight="bold" includeInLayout="false" />
<mx:DataGrid
id="dataGrid"
width="100%"
height="100%"
dataProvider="{visitors}"
doubleClickEnabled="true"
doubleClick="updateVisitor()" >
<mx:columns>
<mx:DataGridColumn dataField="visitorId" headerText="Visitor ID" width="100"/>
<mx:DataGridColumn dataField="vType" headerText="Visitor's Type" />
<mx:DataGridColumn dataField="vPurpose" headerText="Visit Purpose" />
<mx:DataGridColumn dataField="vName" headerText="Visitor's Name" />
<mx:DataGridColumn dataField="vAddress" headerText="Visitor's Address" />
<mx:DataGridColumn dataField="cPerson" headerText="Contact Person" />
<mx:DataGridColumn dataField="cAddress" headerText="Contact Address" />
<mx:DataGridColumn dataField="timeIn" headerText="Time-In" />
<mx:DataGridColumn dataField="timeOut" headerText="Time-Out" />
<mx:DataGridColumn dataField="vPhoto" headerText="Visitor's Photo" />
</mx:columns>
</mx:DataGrid>
<mx:ControlBar horizontalAlign="center">
<mx:Button label="Create Visitor" click="createVisitor()" toolTip="Create a new visitor and store it in the database." />
<mx:Button label="Update Visitor" click="updateVisitor()" enabled="{dataGrid.selectedItem}" toolTip="Update an existing database visitor." />
<mx:Button label="Delete Visitor" click="deleteVisitor()" enabled="{dataGrid.selectedItem}" toolTip="Delete the visitor from the database." />
<mx:Button label="Reload Data" click="loadVisitors()" toolTip="Reload the visitor list from the database." />
</mx:ControlBar>
</mx:VBox>
</mx:Panel>
Visitor.as
package com.visitor.vo
import mx.controls.Image;
import spark.primitives.BitmapImage;
[Bindable]
[RemoteClass(alias="com.visitor.Visitor")]
public class Visitor
public function Visitor()
public var visitorId:Number;
public var vType:String;
public var vPurpose:String;
public var vName:String;
public var vAddress:String;
public var cPerson:String;
public var cAddress:String;
public var timeIn:Date;
public var timeOut:Date;
public var vPhoto: Image;
Visitor.java
package com.visitor;
import java.sql.Blob;
import java.sql.Timestamp;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
@Entity
@Table(name = "visitors")
@NamedQueries( {
@NamedQuery(name = "visitors.findAll", query = "from Visitor"),
@NamedQuery(name = "visitors.byId", query = "select v from Visitor v where v.visitorId= :visitorId") })
public class Visitor {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "visitorId", nullable = false)
private Long visitorId;
@Basic
@Index(name = "vType_idx_1")
@Column(name = "vType", nullable = true, unique = false)
private String vType;
@Basic
@Column(name = "vPurpose", nullable = true, unique = false)
private String vPurpose;
@Basic
@Column(name = "vName", nullable = true, unique = false)
private String vName;
@Basic
@Column(name = "vAddress", nullable = true, unique = false)
private String vAddress;
@Basic
@Column(name = "cPerson", nullable = true, unique = false)
private String cPerson;
@Basic
@Column(name = "cAddress", nullable = true, unique = false)
private String cAddress;
@Basic
@Column(name = "timeIn", nullable = false, unique = false)
private Timestamp timeIn;
@Basic
@Column(name = "timeOut", nullable = true, unique = false)
private Timestamp timeOut;
@Basic
@Column(name = "vPhoto", nullable = true, unique = false)
private Blob vPhoto;
public Visitor() {
super();
public Long getVisitorId() {
return visitorId;
public void setVisitorId(Long visitorId) {
this.visitorId = visitorId;
public String getvType() {
return vType;
public void setvType(String vType) {
this.vType = vType;
public String getvPurpose() {
return vPurpose;
public void setvPurpose(String vPurpose) {
this.vPurpose = vPurpose;
public String getvName() {
return vName;
public void setvName(String vName) {
this.vName = vName;
public String getvAddress() {
return vAddress;
public void setvAddress(String vAddress) {
this.vAddress = vAddress;
public String getcPerson() {
return cPerson;
public void setcPerson(String cPerson) {
this.cPerson = cPerson;
public String getcAddress() {
return cAddress;
public void setcAddress(String cAddress) {
this.cAddress = cAddress;
public Timestamp getTimeIn() {
return timeIn;
public void setTimeIn(Timestamp timeIn) {
this.timeIn = timeIn;
public Timestamp getTimeOut() {
return timeOut;
public void setTimeOut(Timestamp timeOut) {
this.timeOut = timeOut;
public Blob getvPhoto() {
return vPhoto;
public void setvPhoto(Blob vPhoto) {
this.vPhoto = vPhoto;
VisitorService.java
package com.visitor;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.log4j.Logger;
public class VisitorService {
private static final String PERSISTENCE_UNIT = "visitor_db";
private static Logger logger = Logger.getLogger(VisitorService.class);
public VisitorService() {
super();
public List<Visitor> getvisitors() {
logger.debug("** getVisitors called...");
EntityManagerFactory entityManagerFactory = Persistence
.createEntityManagerFactory(PERSISTENCE_UNIT);
EntityManager em = entityManagerFactory.createEntityManager();
Query findAllQuery = em.createNamedQuery("visitors.findAll");
List<Visitor> visitors = findAllQuery.getResultList();
if (visitors != null)
logger.debug("** Found " + visitors.size() + " records:");
return visitors;
public void addUpdateVisitor(Visitor visitor) throws Exception {
logger.debug("** addUpdateVisitor called...");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory(PERSISTENCE_UNIT);
EntityManager em = emf.createEntityManager();
// When passing Boolean and Number values from the Flash client to a
// Java object, Java interprets null values as the default values for
// primitive types; for example, 0 for double, float, long, int, short,
// byte.
if (visitor.getVisitorId() == null || visitor.getVisitorId() == 0) {
// New consultant is created
visitor.setVisitorId(null);
visitor.setTimeIn(new Timestamp(new Date().getTime()));
} else {
visitor.setTimeOut(new Timestamp(new Date().getTime()));
// Existing consultant is updated - do nothing.
EntityTransaction tx = em.getTransaction();
tx.begin();
try {
em.merge(visitor);
tx.commit();
} catch (Exception e) {
logger.error("** Error: " + e.getMessage());
tx.rollback();
throw new Exception(e.getMessage());
} finally {
logger.info("** Closing Entity Manager.");
em.close();
public void deleteVisitor(Long visitorId) {
logger.debug("** deleteVisitor called...");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory(PERSISTENCE_UNIT);
EntityManager em = emf.createEntityManager();
Query q = em.createNamedQuery("visitors.byId");
q.setParameter("visitorId", visitorId);
Visitor visitor = (Visitor) q.getSingleResult();
if (visitor != null) {
EntityTransaction tx = em.getTransaction();
tx.begin();
try {
em.remove(visitor);
tx.commit();
} catch (Exception e) {
logger.error("** Error: " + e.getMessage());
tx.rollback();
} finally {
logger.info("** Closing Entity Manager.");
em.close();
remoting-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
</adapters>
<default-channels>
<channel ref="my-amf" />
</default-channels>
<!-- ADC Demo application -->
<destination id="visitorService">
<properties>
<source>com.visitor.VisitorService</source>
</properties>
</destination>
</service> -
How to store the output of a analog to digital converter into an 2D array
Hi
I am doing my M.Tech Thesis in Image reconstruction and I am using labview for simulation and I want to know how to store the output of a analog to digital converter into an 2D labview array.nitinkajay wrote:
I want to know how to store the output of a analog to digital converter into an 2D labview array.
How exactly are you performing 'Analog to Digital'???
Grabbing image using camera OR performing data acquisition using DAQ card OR some other way????
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT. -
How to store multiple data in one aray at one go?
Hi i am creating a Recipe Cooking Book and i have got a recipe class, ingredient class, equipment class and jFORM GUI. the gui form will have a list and it will contain couple of equipments. the user should be able to select more than 1 equipments which would use the pass- by - value to the recipe class and it will be passed to equipment class.
The problem that encounter is that when i have to select multiple values from list, it should store all selected equipments to array.
This is where i am stuck as i don't know how to store couple of equipment at one creation.
This is my recipe constructor in recipe class
public Recipe(int aRecipeID, String aRecipeName, String aCountryofOrigin,
String aType, String aPreparationTime, String aCookingTime,
String aRecipeDescription, String aProcedure,
ClsEquipment[] aequipment, String aImage1, String aImage2,
String aImage3) {
Create(aRecipeID, aRecipeName, aCountryofOrigin, aType,
aPreparationTime, aCookingTime, aRecipeDescription, aProcedure,
aequipment, aImage1, aImage2, aImage3);
public void Create(int aRecipeID, String aRecipeName,
String aCountryofOrigin, String aType,
String aPreparationTime, String aCookingTime,
String aRecipeDescription, String aProcedure,
ClsEquipment[] aequipment, String aImage1, String aImage2,
String aImage3) {
RecipeID = aRecipeID;
RecipeName = aRecipeName;
CountryofOrigin = aCountryofOrigin;
Type = aType;
PreparationTime = aPreparationTime;
CookingTime = aCookingTime;
RecipeDescription = aRecipeDescription;
Procedure = aProcedure;
*equipment[j] = aequipment[k];*
Image1 = aImage1;
Image2 = aImage2;
Image3 = aImage3;
this is The command that i have in Jform gui
public void jRcreateButton_actionPerformed(ActionEvent e) {
int i=0;
myRecipe.Create(Integer.parseInt(jRidTextField.getText()),jRnameTextField.getText(),jRcountryTextField.getText(),jRtypeTextField.getText(),jRptimeTextField.getText(),jRctimeTextField.getText(),jRdescriptionTextArea.getText(), jRprocedureTextArea.getText(),new ClsEquipment(jAEequipmentList.getSelectedValues()),jRimage1TextField.getText(),jRimage2TextField.getText(),jRimage3TextField.getText());
Let me conclude what i am trying to do. Basically i want the user to select more than 1 equipments from the List and the user should also input other recipe data. once this is done, the should click on create.
when creating one recipe, u need more than 1 equipment so that created recipe should store selected equipments, which i will later on retrieve and display on screen.
can u please guide me where i am goin wrong and how i could fix it.
thank you in advance
Edited by: JAVABABY on Feb 18, 2008 8:40 AM*equipment[j] = aequipment[k];*JList's getSelectedValues() method returns an array of Objects, so if you wanted to store it into another Object[] reference, you'd just use
equipment = aequipment;But, you are storing it as an Equipment array, so you'll need to loop over the Object array and cast each element to an Equipment reference, and store it into the Equipment array. Something like this:
equipment = new Equipment[aequipment.length];
for (each element x in aequipment) {
equipment[x] = (Equipment)aequipment[x];
}
Maybe you are looking for
-
How do have more space after deleting my apps from iTunes. I just deleted over 18 apps and then I sync after clearing the trash but still my space didn't move and its still showing that i have a lot of apps after deleting them. Please advice
-
Default text source for text tab in purchase requistion.
Hi, issue is about text which pops up when someone try to create purchase requisition using me51n. some text shows up under Text-item texts-item text at document level.This text should not be populated when someone creates purchase requisition.c
-
im running on windows 7 what can i do HELP ME
-
Im fairly new to Premiere and haven't really encountered this problem before. I used a Nikon E4200 to create this video and when I play back the audio the sound cuts out where I've highlighted the track. If anybody could help me figure out what this
-
How to change e-mail address in iCloud IMAP
how to change e-mail address in iCloud IMAP. i have to change it to another e-mail address. please help please find in image.