How can I use XStream to persist complicated Java Object  to XML & backward

Dear Sir:
I met a problem as demo in my code below when i use XTream to persist my Java Object;
How can I use XStream to persist complicated Java Object to XML & backward??
See
[1] main code
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class PhoneList {
     ArrayList<PhoneNumber> phones;
     ArrayList<Person> person;
     private PhoneList myphonelist ;
     private LocationTest location;
     private PhoneList(String name) {
     phones = new ArrayList<PhoneNumber>();
     person = new ArrayList<Person>();
     public ArrayList<PhoneNumber> getphones() {
          return phones;
     public ArrayList<Person> getperson() {
          return person;
     public void addPhoneNumber(PhoneNumber b1) {
          this.phones.add(b1);
     public void removePhoneNumber(PhoneNumber b1) {
          this.phones.remove(b1);
     public void addPerson(Person p1) {
          this.person.add(p1);
     public void removePerson(Person p1) {
          this.person.remove(p1);
     public void BuildList(){
          location = new LocationTest();
          XStream xstream = new XStream();
          myphonelist = new PhoneList("PhoneList");
          Person joe = new Person("Joe, Wallace");
          joe.setPhone(new PhoneNumber(123, "1234-456"));
          joe.setFax(new PhoneNumber(123, "9999-999"));
          Person geo= new Person("George Nixson");
          geo.setPhone(new PhoneNumber(925, "228-9999"));
          geo.getPhone().setLocationTest(location);          
          myphonelist.addPerson(joe);
          myphonelist.addPerson(geo);
     public PhoneList(){
          XStream xstream = new XStream();
          BuildList();
          saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
     public void saveStringToFile(String fileName, String saveString) {
          BufferedWriter bw = null;
          try {
               bw = new BufferedWriter(
                         new FileWriter(fileName));
               try {
                    bw.write(saveString);
               finally {
                    bw.close();
          catch (IOException ex) {
               ex.printStackTrace();
          //return saved;
     public String getStringFromFile(String fileName) {
          BufferedReader br = null;
          StringBuilder sb = new StringBuilder();
          try {
               br = new BufferedReader(
                         new FileReader(fileName));
               try {
                    String s;
                    while ((s = br.readLine()) != null) {
                         // add linefeed (\n) back since stripped by readline()
                         sb.append(s + "\n");
               finally {
                    br.close();
          catch (Exception ex) {
               ex.printStackTrace();
          return sb.toString();
     public  String convertToXML(PhoneList phonelist) {
          XStream xstream = new  XStream(new DomDriver());
          xstream.setMode(xstream.ID_REFERENCES) ;
          return xstream.toXML(phonelist);
     public static void main(String[] args) {
          new PhoneList();
}[2].
import java.io.Serializable;
import javax.swing.JFrame;
public class PhoneNumber implements Serializable{
       private      String      phone;
       private      String      fax;
       private      int      code;
       private      String      number;
       private      String      address;
       private      String      school;
       private      LocationTest      location;
       public PhoneNumber(int i, String str) {
            setCode(i);
            setNumber(str);
            address = "4256, Washington DC, USA";
            school = "Washington State University";
     public Object getPerson() {
          return null;
     public void setPhone(String phone) {
          this.phone = phone;
     public String getPhone() {
          return phone;
     public void setFax(String fax) {
          this.fax = fax;
     public String getFax() {
          return fax;
     public void setCode(int code) {
          this.code = code;
     public int getCode() {
          return code;
     public void setNumber(String number) {
          this.number = number;
     public String getNumber() {
          return number;
     public void setLocationTest(LocationTest bd) {
          this.location = bd;
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(location);
        f.getContentPane().add(location.getControls(), "Last");
        f.setSize(400,400);
        f.setLocation(200,200);
        f.setVisible(true);
     public LocationTest getLocationTest() {
          return location;
     }[3].
package test.temp;
import java.io.Serializable;
public class Person implements Serializable{
     private String           fullname;
       @SuppressWarnings("unused")
     private PhoneNumber      phone;
       @SuppressWarnings("unused")
     private PhoneNumber      fax;
     public Person(){
     public Person(String fname){
            fullname=fname;           
     public void setPhone(PhoneNumber phoneNumber) {
          phone = phoneNumber;
     public void setFax(PhoneNumber phoneNumber) {
          fax = phoneNumber;
     public PhoneNumber getPhone() {
          return phone ;
     public PhoneNumber getFax() {
          return fax;
    public String getName() {
        return fullname ;
    public void setName(String name) {
        this.fullname      = name;
    public String toString() {
        return getName();
}[4]. LocationTest.java
package test.temp;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class LocationTest extends JPanel implements ChangeListener
    Ellipse2D.Double ball;
    Line2D.Double    line;
    JSlider          translate;
    double           lastTheta = 0;
    public void stateChanged(ChangeEvent e)
        JSlider slider = (JSlider)e.getSource();
        String name = slider.getName();
        int value = slider.getValue();
        if(name.equals("rotation"))
            tilt(Math.toRadians(value));
        else if(name.equals("translate"))
            moveBall(value);
        repaint();
    protected void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        if(ball == null)
            initGeom();
        g2.setPaint(Color.green.darker());
        g2.draw(line);
        g2.setPaint(Color.red);
        g2.fill(ball);
    private void initGeom()
        int w = getWidth();
        int h = getHeight();
        int DIA = 30;
        int padFromEnd = 5;
        line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
        double x = line.x2 - padFromEnd - DIA;
        double y = line.y2 - DIA;
        ball = new Ellipse2D.Double(x, y, DIA, DIA);
        // update translate slider values
        int max = (int)line.getP1().distance(line.getP2());
        translate.setMaximum(max);
        translate.setValue(max-padFromEnd);
    private void tilt(double theta)
        // rotate line from left end
        Point2D pivot = line.getP1();
        double lineLength = pivot.distance(line.getP2());
        Point2D.Double p2 = new Point2D.Double();
        p2.x = pivot.getX() + lineLength*Math.cos(theta);
        p2.y = pivot.getY() + lineLength*Math.sin(theta);
        line.setLine(pivot, p2);
        // find angle from pivot to ball center relative to line
        // ie, ball center -> pivot -> line end
        double cx = ball.getCenterX();
        double cy = ball.getCenterY();
        double pivotToCenter = pivot.distance(cx, cy);
        // angle of ball to horizon
        double dy = cy - pivot.getY();
        double dx = cx - pivot.getX();
        // relative angle phi = ball_to_horizon - last line_to_horizon
        double phi = Math.atan2(dy, dx) - lastTheta;
        // rotate ball from pivot
        double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
        double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
        ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
        lastTheta = theta;  // save theta for next time
    private void moveBall(int distance)
        Point2D pivot = line.getP1();
        // ball touches line at distance from pivot
        double contactX = pivot.getX() + distance*Math.cos(lastTheta);
        double contactY = pivot.getY() + distance*Math.sin(lastTheta);
        // find new center location of ball
        // angle lambda = lastTheta - 90 degrees (anti-clockwise)
        double lambda = lastTheta - Math.PI/2;
        double x = contactX + (ball.width/2)*Math.cos(lambda);
        double y = contactY + (ball.height/2)*Math.sin(lambda);
        ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
    JPanel getControls()
        JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
        translate = getSlider("distance from end",  "translate", 0, 100, 100,25, 50);
        JPanel panel = new JPanel(new GridLayout(0,1));
        panel.add(rotate);
        panel.add(translate);
        return panel;
    private JSlider getSlider(String title, String name, int min, int max,
                              int value, int minorSpace, int majorSpace)
        JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
        slider.setBorder(BorderFactory.createTitledBorder(title));
        slider.setName(name);
        slider.setPaintTicks(true);
        slider.setMinorTickSpacing(minorSpace);
        slider.setMajorTickSpacing(majorSpace);
        slider.setPaintLabels(true);
        slider.addChangeListener(this);
        return slider;
}OK, My questions are:
[1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
[2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
Thanks a lot!!

Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.

Similar Messages

  • How can I use LogOutComponent programatically in a Java iView?

    Hi,
    Can someone point me to the jar file(s) that I need to reference in my portal application project (Java PDK) to use LogOutComponent? Which ones do I need and where can I get them
    I got the class file 'com.sap.portal.navigation.masthead_core.jar' from the Portal server but am not sure if this file is the only one that I need to use to incorporate LogOutComponent in my code.
    Also, can somebody tell me that how can I call this component from my AbstractPortal Component to call logout programatically? I am not using JSPs and would ideally not like to redirect the response to the URL of this component but rather use the object in my Java code. Sample code to help with this would be appreciated.
    Thank you,
    - Vik.

    Hi there,
    To log a user out of the Portal I decided to go the route of: UMFactory.getAuthenticator().logout(req, res)
    Code is below.
    Thanks for your replies,
    - Vik.
    <code>
    IAuthentication Authen = UMFactory.getAuthenticator();
    HttpServletRequest req = request.getServletRequest();
    HttpServletResponse res = request.getServletResponse(true);
    //logoff user from Portal
    Authen.logout(req, res);
    </code>

  • How can i use contactless access cards in java

    hello everybody,
    I just want to know that can I use the contact less access cards in java. Plz tell me
    thank you

    It isn't a simple component.It is a windows service.I think a bridge only can solve the problem like .dll .olb and so on.
    Please don't think the com and dcom.I just want to know how can I call the interface of a windows service in java.
    Please help me .
    and please tell me more detail.
    Thanks.

  • How Can I use Mysql's  PROCEDURE by Java Can you give me sample???

    �������^���������������H�iBEGIN�`END�u���b�N�j�@��TOP
    ORACLE�@MSSQL�@SSA�@MySQL�@
    ���{�I���������������������������B
    MySQL�������A ORACLE��MSSSQL��������������BEGIN�`END�u���b�N�����s�������������������������B
    ���������s�������������K���X�g�A�h�v���O�����������R���p�C�������K�v�����������B
    �i�����F�������������������A���w�E�������������K�r�����������j
    --drop PROCEDURE sp_hoge;
    --�f���~�^�����X��������
    delimiter //
    CREATE PROCEDURE sp_hoge()
    DETERMINISTIC
    BEGIN
    /* �������� */
    DECLARE mystr VARCHAR(20);
    DECLARE mycnt INTEGER(2);
    /* �l������ */
    SET mycnt = 0;
    SET mystr = '����';
    /* IF�� */
    IF mycnt = 0 THEN
    SET mystr = '�����Q';
    select mystr;
    ELSE
    select '�����R';
    END IF;
    /* CASE�� */
    CASE extract(month from now())
    WHEN 1 THEN SET mystr = '1��';
    WHEN 2 THEN SET mystr = '2��';
    WHEN 3 THEN SET mystr = '3��';
    WHEN 4 THEN SET mystr = '4��';
    ELSE SET mystr = '1�`4�����O';
    END CASE;
    select mystr;
    /* WHILE-LOOP */
    WHILE mycnt <= 5 DO
    SET mycnt = mycnt + 1;
    select mycnt;
    END WHILE;
    /* BEGIN-END�u���b�N������SELECT�������s */
    /* PROCEDURE�������\�iFUNCTION���������������j */
    select * from help_topic;
    END//
    delimiter ;
    --�X�g�A�h�v���V�[�W�����s
    call sp_hoge();
    �X�g�A�h�v���V�[�W�����T���v���i�J�[�\�����g�p������LOOP�����j�@��TOP
    ORACLE�@MSSQL�@SSA�@MySQL�@
    �J�[�\�����g�p����LOOP�������T���v�������B
    �����p�����[�^���w�����������������Y�������������������A���E���w�X�^�b�t�x�������������A�����������w�c���X�^�b�t�F�x���\���������B
    --drop PROCEDURE sp_hoge;
    --�f���~�^�����X��������
    delimiter //
    CREATE PROCEDURE sp_hoge(inum INTEGER(3))
    DETERMINISTIC
    BEGIN
    /* �������� */
    /* �J�[�\���g�p�����f�[�^�L�����f���g�p */
    DECLARE done INT DEFAULT 0;
    /* �������O������ */
    DECLARE v_mystr VARCHAR(20);
    /* �J�[�\���g�p�� */
    DECLARE v_empnm VARCHAR(40);
    DECLARE v_job VARCHAR(20);
    /* �J�[�\������ �� �����������������`���� */
    DECLARE cur1 CURSOR FOR
    select empnm,job from kemp where deptno = inum;
    /* �f�[�^��������LOOP�E�o�p���������� */
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
    /* �J�[�\���I�[�v�� */
    OPEN cur1;
    /* LOOP */
    LOOPPROC:REPEAT
    FETCH cur1 INTO v_empnm,v_job;
    IF NOT done THEN
    IF v_job = '�X�^�b�t' THEN
    SET v_mystr = '�c���X�^�b�t�F';
    ELSE
    SET v_mystr = '';
    END IF;
    select CONCAT(v_mystr,v_empnm);
    /* ������������LOOP���E�o����������LEAVE�� */
    /* LEAVE LOOPPROC; */
    END IF;
    UNTIL done END REPEAT;
    /* �J�[�\���N���[�Y */
    CLOSE cur1;
    END//
    --�f���~�^���Z�~�R�����i�f�t�H���g�j������������
    delimiter ;
    --�X�g�A�h�v���V�[�W�����s
    call sp_hoge(1);
    12.2. Control Flow Functions
    CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END
    CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
    The first version returns the result where value=compare_value. The second version returns the result for the first condition that is true. If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE part.
    mysql> SELECT CASE 1 WHEN 1 THEN 'one'
    -> WHEN 2 THEN 'two' ELSE 'more' END;
    -> 'one'
    mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;
    -> 'true'
    mysql> SELECT CASE BINARY 'B'
    -> WHEN 'a' THEN 1 WHEN 'b' THEN 2 END;
    -> NULL
    The default return type of a CASE expression is the compatible aggregated type of all return values, but also depends on the context in which it is used. If used in a string context, the result is returned as a string. If used in a numeric context, then the result is returned as a decimal, real, or integer value.
    Note: The syntax of the CASE expression shown here differs slightly from that of the SQL CASE statement described in Section 17.2.10.2, �gCASE Statement�h, for use inside stored routines. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.
    IF(expr1,expr2,expr3)
    If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.
    mysql> SELECT IF(1>2,2,3);
    -> 3
    mysql> SELECT IF(1<2,'yes','no');
    -> 'yes'
    mysql> SELECT IF(STRCMP('test','test1'),'no','yes');
    -> 'no'
    If only one of expr2 or expr3 is explicitly NULL, the result type of the IF() function is the type of the non-NULL expression.
    expr1 is evaluated as an integer value, which means that if you are testing floating-point or string values, you should do so using a comparison operation.
    mysql> SELECT IF(0.1,1,0);
    -> 0
    mysql> SELECT IF(0.1<>0,1,0);
    -> 1
    In the first case shown, IF(0.1) returns 0 because 0.1 is converted to an integer value, resulting in a test of IF(0). This may not be what you expect. In the second case, the comparison tests the original floating-point value to see whether it is non-zero. The result of the comparison is used as an integer.
    The default return type of IF() (which may matter when it is stored into a temporary table) is calculated as follows:
    Expression Return Value
    expr2 or expr3 returns a string string
    expr2 or expr3 returns a floating-point value floating-point
    expr2 or expr3 returns an integer integer
    If expr2 and expr3 are both strings, the result is case sensitive if either string is case sensitive.
    Note: There is also an IF statement, which differs from the IF() function described here. See Section 17.2.10.1, �gIF Statement�h.
    IFNULL(expr1,expr2)
    If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. IFNULL() returns a numeric or string value, depending on the context in which it is used.
    mysql> SELECT IFNULL(1,0);
    -> 1
    mysql> SELECT IFNULL(NULL,10);
    -> 10
    mysql> SELECT IFNULL(1/0,10);
    -> 10
    mysql> SELECT IFNULL(1/0,'yes');
    -> 'yes'
    The default result value of IFNULL(expr1,expr2) is the more �ggeneral�h of the two expressions, in the order STRING, REAL, or INTEGER. Consider the case of a table based on expressions or where MySQL must internally store a value returned by IFNULL() in a temporary table:
    mysql> CREATE TABLE tmp SELECT IFNULL(1,'test') AS test;
    mysql> DESCRIBE tmp;
    -------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    -------------------------------------------+
    | test | char(4) | | | | |
    -------------------------------------------+
    In this example, the type of the test column is CHAR(4).
    NULLIF(expr1,expr2)
    Returns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.
    mysql> SELECT NULLIF(1,1);
    -> NULL
    mysql> SELECT NULLIF(1,2);
    -> 1
    Note that MySQL evaluates expr1 twice if the arguments are not equal.
    Previous / Next / Up / Table of Contents
    User Comments
    Posted by I W on July 12 2005 5:52pm [Delete] [Edit]
    Don't use IFNULL for comparisons (especially not for Joins)
    (example:
    select aa from a left join b ON IFNULL(a.col,1)=IFNULL(b.col,1)
    It's terrible slow (ran for days on two tables with approx 250k rows).
    Use <=> (NULL-safe comparison) instead. It did the same job in less than 15 minutes!!
    Posted by [name withheld] on November 10 2005 12:12am [Delete] [Edit]
    IFNULL is like oracle's NVL function (these should help people searching for NVL() ..)
    Posted by Philip Mak on May 26 2006 7:14am [Delete] [Edit]
    When using CASE, remember that NULL != NULL, so if you write "WHEN NULL", it will never match. (I guess you have to use IFNULL() instead...)
    Posted by Marc Grue on June 24 2006 2:03pm [Delete] [Edit]
    You can ORDER BY a dynamic column_name parameter using a CASE expression in the ORDER BY clause of the SELECT statement:
    CREATE PROCEDURE `orderby`(IN _orderby VARCHAR(50))
    BEGIN
    SELECT id, first_name, last_name, birthday
    FROM table
    ORDER BY
    -- numeric columns
    CASE _orderby WHEN 'id' THEN id END ASC,
    CASE orderby WHEN 'desc id' THEN id END DESC,
    -- string columns
    CASE orderby WHEN 'firstname' THEN first_name WHEN 'last_name' THEN last_name END ASC,
    CASE orderby WHEN 'descfirst_name' THEN first_name WHEN 'desc_last_name' THEN last_name END DESC,
    -- datetime columns
    CASE _orderby WHEN 'birthday' THEN birthday END ASC,
    CASE orderby WHEN 'desc birthday' THEN birthday END DESC;
    END
    Since the CASE expression returns the "compatible aggregated type of all return values", you need to isolate each column type in a separate CASE expression to get the desired result.
    If you mixed the columns like
    CASE _orderby
    WHEN 'id' THEN id
    WHEN 'first_name' THEN first_name
    ...etc...
    END ASC
    .. both the id and first_name would be returned as a string value, and ids would be sorted as a string to '1,12,2,24,5' and not as integers to '1,2,5,12,24'.
    Note that you don't need a "ELSE null" in the CASE expressions, since the CASE expression automatically returns null if there's no match. In that case, you get a "null ASC" in your ORDER BY clause which doesn't affect the sort order. If for instance orderby is 'descfirst_name', the ORDER BY clause evaluates to:
    ORDER BY null ASC, null DESC, null ASC, first_name DESC, null ASC, null DESC
    Effectively the same as "ORDER BY first_name DESC". You could even add a new set of CASE expressions for a second order column (or more..) if you like.
    Add your own comment.

    What is that post supposed to be?

  • How can I use JavaScript extention functions with Xalan for transforming XML with XSL

    While transforming standart XML and XSL files to HTML with this servlet:
    package mypackage1;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.net.URL;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    import org.mozilla.javascript;
    public class Servlet2 extends HttpServlet
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    try
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Source xmlSource = new StreamSource(new FileReader("c:/aaa.xml"));
    Source xslSource = new StreamSource(new FileReader("c:/bbb.xsl"));
    Transformer transformer = tFactory.newTransformer(xslSource);
    transformer.transform (xmlSource, new StreamResult(out));
    catch (Exception e)
    e.printStackTrace();
    everything is going ok,
    but when try to use javascript function in XSL file, for example like in this:
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:lxslt="http://xml.apache.org/xslt" xmlns:my-ext="ext1"
    extension-element-prefixes="my-ext">
    <lxslt:component prefix="my-ext"
    functions="getdate">
    <lxslt:script lang="javascript">
    function getdate() {
    var d = new Date();
    return d.toUTCString();
    </lxslt:script>
    </lxslt:component>
    <xsl:template match="/">
    <p><xsl:copy-of select="my-ext:getdate()"/></p>
    </xsl:template>
    </xsl:stylesheet>
    recieve error-message:
    XSL-1000: (Fatal Error) Error while parsing XSL file (Extension function namespace should start with 'http://www.oracle.com/XSL/Transform/java/'.).
    What kind of namespace I should specify?

    Hello, Paul.
    I'm sure you may not use JavaScript as a language for creating XSLT extention functions with Oracle XDK Parser. This is since parser might have JavaScript interpreter to work with JavaScript, but it has not.
    If you need to build any XSLT extention functions you must build them as Java class' static methods.
    After that, you define the usage of the class by mean of namespace declaration as:
    xmlns:your-ns="http://www.oracle.com/XSL/Transform/java/yourpackage.Yourclass"
    (Prefix "http://www.oracle.com/XSL/Transform/java/" may differs if you use non-Oracle XML parser)
    and use class' static method in XSLT:
    <xsl:value-of select="your-ns.staticMethodName(paramsIfAny)"/>
    In your case you may wish to use standard Date class:
    xmlns:date="http://www.oracle.com/XSL/Transform/java/java.util.Date"
    <xsl:value-of select="date:toString(date:new)"/>

  • How can i use multi-windows technology in JAVA

    I am developing a java application with JBuilder4, and now i want to make a multi-window application,which can be created dynamically, also the window can contain the button and line drawing i need.
    Please reply in detail because of my first learning java, thanks.

    You can try JInternalFrame, here is the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html
    Good Luck!

  • How can I use XMLBeans in a Web Services client?

    How can I use XMLBeans in a standalone Java client with a Web Service?
    I posted the message below earlier in the year, but have not yet been successful
    in my
    attempts.
    regards
    Eddie
    Hi,
    I'm trying to using XMLBeans to send a document to a web service from a standalone
    Java client. I'm using the PurchaseOrder (easypo) example document, and the service
    expects a parameter of type PurchaseOrderDocument. The client proxy class generated
    by WebLogic Workshop, however, expects to send a parameter of type PurchaseOrder.
    In the client, I can instantiate a PurchaseOrderDocument, and then obtain a PurchaseOrder
    (e.g. pod.getPurchaseOrder() ), but the returned class is not compatible with
    the PurchaseOrder type that the client proxy expects.
    In a previous attempt (not using Workshop), the client would not compile because
    it expected to send a non-abstract class with a public default constructor (presumably
    a JAX-RPC requirement), and XMLBeans had generated an interface.
    Any help would be greatly appreciated!
    thanks & regards
    Eddie

    I have been experiencing similar problems with the HTML Editor and have managed to find an answer that should start to answer some of my questions. The Apex HTML Editor Standard is actually an HTML editor called FCKeditor. The FCKeditor has a Javascript API that can be found at http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API. Unfortuately this doesn't seem to give the whole answer and I found more at http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:49607.
    I needed to get the text entered within my html editor standard (e.g. P1_MYTEXT) and use it within my javascript function. I did this by using the following script
    <script language="JavaScript" type="text/javascript">
    function showtext(){
    var oEditor = FCKeditorAPI.GetInstance('P1_MYTEXT');
    var editortext = escape(oEditor.GetXHTML(oEditor.FormatOutput));
    alert(editortext);
    </script>
    Hope this helps.
    Matthew

  • How can i use or embed  the ' C'  language in java

    thanks a lot friends for your suggestion on using 'c' language to implement the control of the keyboard ie. to prevent a key stroke of : ctrl+alt+delete keys from closing a running java application. i was advised that it won't be possible to implement this with java language, the use of 'C' language was suggested. i then wish to ask the following:
    1. how can i use 'C'language in a java program and be able to compile to program so that the resultant program can help me prevent the closing of my java-application when the user of the application presses the following keys : ctrl+alt+delete. i don't even know the c language at all. how can i start and how can i combine the resultant code with java.
    2. i'm thinking of creating an application that retrieves information from a database, like microsoft sql or oracle, and displays the resultant data from a table, say STUDENT TABLE, in a java application using the JTable class. i don't even know how to use this JTable but i've seen it used and know it will suit what i have in mind.
    3. how can i make the table dynamic, ie. how can i make the table to immediately register / show the result of an update to the 'STUDENT' table in the database.
    4. THANKS FOR YOUR HELP IN ADVANCE. i will most appreciate it if you can give me a sample code or a site where i download one. once again thanks.

    Good luck disabling Ctrl+Alt+Del! I've read quite a bit about it, and at least on Windows 2000 (not sure about NT) or higher, disabling it is next to impossible. Problem is CAD is a system command, and the OS doesn't even send the keys to the active program. Ctrl+Alt+Del is handled by the GINA (Graphical Identification and Authentication) DLL installed on the system. You'll have to write and export the functions you need and change the GINA DLL used by the system to your own. Bear in mind that any small mistake in the dll can cause you to lose access to your computer if you haven't taken precautions!
    On Windows 95/98, disabling Ctrl+Alt+Del is fairly easy as you just have to write some simple native code to fool the system that a password protected screensaver is running.
    I've provided a link regarding winlogon and GINA here, but you've been forewarned!
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/security/winlogon_and_gina.asp

  • HT3354 how can i use one table for reference to another

    how can i use a table for a referance to another eg when i type a word in a cell, i will like it to match the word with another table then return the information in the cell i am using

    you can use vlookup() (or any of the lookup family of functions) to locate an item based on a key value:
    Here is an example of something you can do with two tables:
    The table on the right is title "Data" and stores a list of names with age and favorite color.
    The table on the left uses the value in the first column to lookup up information in the table Data
    in the table on the left:
    B2=IFERROR(A2&" is " & VLOOKUP(A2, Data :: A:D, 2, 0)&" years old and likes the color "& VLOOKUP(A2, Data :: A:D, 3, 0), "NOT FOUND")
    I know this look complicated.  so I'll break it up into smalled pieces:
    first the "&" is called the concatenate operator and joins two strings.  like this:
    a string is a set of characters between double quotes.
    so "string 1" & "string 2" becomes "string 1string2"  or "Sam " & "Jones" becomes "Sam Jones"
    you can use cell references instead of strings directly in which case the concatenation is performed on the contents of the cells.
    so if cell A1 contains "Hi " and the cell A2 contains "There"  then A1 & A2 will result in "Hi There"
    so you could add the formula
    A3=A1 & A2
    this is short hand for select cell A3 then type everything including the A3 so that A3 contains "=A1 & A2" (omit the double quote)
    OK.  So the formula I provided concatenates several items together:
    it concatenates A2, then the string " is " then a formula, then the string " years old and likes the color " then a formula
    the two formulas (highlighted in blue) perform a lookup of the value in cell A2 in columns A thru D of the table named "Data".  If if finds the value in cell A2 in the first column of the lookup range in the table Data (column A) then it returns the value from the same row but in the second or third column.
    all that is in a function calld iserror() to trap the condition where the calue you enter in A2 does not exist in the table Data:
    You will find the Numbers users guide and function reference helpful.  You can download then from Apple here:
    http://support.apple.com/manuals/#productivitysoftware

  • How can i use the project code instead of project xml?

    hello
    i use the sessionbean+toplink structure,after i finish the o-r mapping by using the mapping work bench,i generate the project xml file,then in the "session.xml" file,i refer to the project xml,then i can use it from sessionbean.
    i hear that if i use the project code instead of project xml file,it will be more performant,is that true?
    otherwise,how can i use the project code instead of project xml file?i mean, in "session.xml", i can use the "<project-xml>" tag to refer to the project xml file,then in my session bean,i get the server session by read the "session.xml" file.but if i use the project code,how can i refer it from the "session.xml"?the examples that come with the toplink installation only tell me how can i use the project xml file within the session bean,it don't give me any clue about using the project code in the sesion bean,who can give me a step-by-step instruction and code snippet?
    thank you very much?

    There is a slight performance gain during session load at startup but there is no difference at runtime. The choice of which to use is dependent upon you build process. Whether it is easier to submit a new version of the class into the comile build process vs an XML file. In most cases it is just a preference of the development team.
    When you use the project-class you'll need to generate the source code and compile it into your system. Typically it is packaged with the persistent classes. You may need to configure your environment so that the class-loaders have access to these classes (same for the XML case).
    When using the project-class you simply replace the project-xml entry like this:
    <project-class>oracle.toplink.demos.employee.relational.EmployeeProject</project-class>
    The DTD for the session.xml file is found at <TOPLINK_HOME>\core\sessions_4_5.dtd. It is also in the documentation at:
    http://otn.oracle.com/docs/products/ias/doc_library/90200doc_otn/toplink.903/b10064/a-sessio.htm#634246
    Doug Clarke
    Product Manager
    Oracle9iAS TopLink

  • How can i use session to save properties?

    How can i use session to save properties?

    Hi,
    Session Tracking is one of the most powerful features of Servlets and JSP. Basically, the servlet engine takes care of using Cookies in the right way to preserve state across successive requests by the same user. Your servlet just needs to call a single method (getSession) and it has access to a persistent hashtable of data that's unique to the current user.
    Otherwise Visit Servlet Essentials tutorial
    http://www.novocode.com/doc/servlet-essentials/

  • How can i use a string name as an onject name.please help!

    hi it seems like an easy one but i can not find it anywhere.how can i use the name of a string as a name of an object such as the code(my problem is the code)...
    public void oda(String name1){ 
    String name2=name1+"s";
    String name3=name1+"ss";
    TextArea name1=new TextArea();
    TextArea name2=new TextArea();
    TextArea name3=new TextArea();
    i think my problem is clear but to be sure..
    how can i give a name to an object in my textarea which is already using as a string.
    thank u .

    it get very compilcated to change the name of the object you created. identity is something you don't want to mess with..you can do it by usin reflection, but it will slow down your application and (again) is quite complicated...
    a simple solution (and more object-oriennted) is to create a Wrapper, Decorator, or Extends the class.
    example
    public class MyTextBox{
        private String name = null;
        private boolean value = false;
        private JTextArea txtArea = null;
        public MyTextBox(String name, boolean value){
            txtArea = new JTextArea();
            this.value = value;
            this.isOn = isOn;
        public String getComponentName(){  return name; }
        pubic boolean getComponentValue(){ return value; }
        public JTextArea getTextArea(){ return area; }
    }

  • How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes?

    How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes? I wanted my teenager's AppleID to be different from mine so that she couldn't charge stuff to my AppleID, therefore I created me another one. Now when I go to Sync either device, it tells me that this IOS device can only be synced with one AppleID. Then I get a message to erase it, not going to do that, lol. If I logout as one ID and login as the other, will it still retain all synced information on the PC from the first IOS device? If I can just log in out of the AppleID, then I have no problem doing that as long as the synced apps, music, etc stays there for both. I am not trying to copy from one to the other, just want to make sure I have a backup for the UhOh times. If logging in and out on the same PC of multiple AppleIDs is acceptible then I need to be able to authorize the PC for both devices. Thanks for the help. I am new to the iOS world.

    "Method Three
    Create a separate iTunes library for each device. Note:It is important that you make a new iTunes Library file. Do not justmake a copy of your existing iTunes Library file. If iTunes is open,quit it.
    This one may work. I searched and searched on the website for something like this, I guess I just didn't search correctly, lol. I will give this a try later. My daughter is not be back for a few weekends, therefore I will have to try the Method 3 when she comes back for the weekend again. "
    I forgot to mention that she has a PC at her house that she also syncs to. Would this cause a problem. I am already getting that pop up saying that the iPod is synced to another library (even though she is signed in with her Apple ID to iTunes) and gives the pop up to Cancel, Erase & Sync, or Transfer Purchases. My question arose because she clicked on "Erase & Sync" by mistake when she plugged the iPod to her PC the first time. When the iPod was purchased and setup, it was synced to my PC first. When she went home, she hooked it up to her PC and then she erased it by accident. I was able to restore all the missing stuff yesterday using my PC. However, even after doing that it still told me the next time I hooked it up last night that the iPod was currently synced with a different library. Hopefully, you can help me understand all this. She wants to sync her iPod and also backup her iPod at both places. Both PCs have been authorised. Thanks

  • How can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    how can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    If you are just visiting Singapore, then leave the account as it is. If you have moved there, then view your account using the iTunes app on a Mac or PC and change the country/region to your current location and address. If you do not have a bank card, you can fund your account using iTunes gift cards if available in Singapore.

  • How can I use one photo twice in a slideshow

    I am in iPhoto '11 9.4.3 making a slideshow to send to iDVD for my mother-in-laws funeral next Wednesday.
    How can I use this one particular photo of her several times in the slide show.
    I have tried copy/past and that does not seem to work.
    Thanx in advance

    I would just duplicate the picture several times and keep inserting duplicates ...

Maybe you are looking for

  • How can I add more than one song to fit the length of the slideshow

    I would like to add more than one song to my slideshow. I do not want to repeat the same song more than once. Is there a way to add more than one song to a slideshow?

  • Error while starting NW server and j2ee server is getting stopped.

    Hi, I am working in NW04s. It contains ABAP sp5 and java sp9 versions. The server was working find till ten days back. After the gap of ten days, when i started to work on this SAP system, i was not able to start the j2ee server. During the startup o

  • Problem in loading Designer Window

    Hello Everyone. I would to compliment myself, it's my first time here on this forum. So... I'm having a problem in Visual Studio.Net 2013 and I don't know how to fix it. It appears when I load the "designer" mode in Visual Basic or C# projects. I'm s

  • Very very urgent Discoverer reports for non oracle applications

    Hi, My client is using discoverer 10g with R12.He is using different non oracle applications like BRM Application (database is oracle only) for that they wants to develop discoverer reports.It is possible to integrate with non oracle applications wit

  • Server failed to start up

    I tried to configure the Managed Server in Weblogic 10.3, but i had the exception below. The exception occured after that i was put a jar in classpath of the "start server".... without this, the server works very well. Someone could help me? <22/10/2