User Defined Formulae
Hi All,
I have a requirement to execute very simple user defined
formulae. The user would create an object of a certain class, and
in certain cases the value of one of the properties would depend
upon another object of the same class that had been created
earlier.
So assuming the objects have a property called "Price", I
would like to enable the user to create an object A with a Price of
30 and object B with a Price equal to the objectA.Price * 2.
I am guessing that the way to do this is to store a formula
as a string in the database
eg objectB.Price = objectA.Price * 2;
But how do I retrieve that formula and execute it?
Can I convert the string to become a function, if so can you
show me the code for that?
Any suggestions gratefully received.
This is actually quite difficult in AS, since there is no
true eval() function, thus no way to execute a string tht looks
like an expression.
I think you are going to have to parse your strings yourself,
and execute the operations manually.
To support this in our app, the use must create the
expression, then publish the app. Publishing builds a string
defining an mxml component, using the strings they wrote. When the
published component is compiled and run, the epressions execute
normally.
Tracy
Similar Messages
-
Error while processing a user defined screen
Dear Experts,
We have developed an add on for our client in which we have a user defined screen before adding the GRPO. While adding that we are getting the error to generate this document first define the numbering series in the administration module.
this is happening only after we upgraded to the 2007 B PL 10 version. till that there was no problem. We are unable to remove and replace the UDO and UDT as we have data in it.
due to this we are unable to proceed with the GRPO.
Please help us.
thanks and regards,
Yeshwanth PrakashHi,
Please search the forum before posting a new message.
There are endless posts about that error.
Regards,
Vítor Vieira -
Issue with xsd Data type mapping for collection of user defined data type
Hi,
I am facing a issue with wsdl for xsd mapping for collection of user defined data type.
Here is the code snippet.
sample.java
@WebMethod
public QueryPageOutput AccountQue(QueryPageInput qpInput)
public class QueryPageInput implements Serializable, Cloneable
protected Account_IO fMessage = null;
public class QueryPageOutput implements Serializable, Cloneable
protected Account_IO fMessage = null;
public class Account_IO implements Serializable, Cloneable {
protected ArrayList <AccountIC> fintObjInst = null;
public ArrayList<AccountIC>getfintObjInst()
return (ArrayList<AccountIC>)fintObjInst.clone();
public void setfintObjInst(AccountIC val)
fintObjInst = new ArrayList<AccountIC>();
fintObjInst.add(val);
Public class AccountIC
protected String Name;
protected String Desc;
public String getName()
return Name;
public void setName(String name)
Name = name;
For the sample.java code, the wsdl generated is as below:
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions
name="SimpleService"
targetNamespace="http://example.org"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://example.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
>
<wsdl:types>
<xs:schema version="1.0" targetNamespace="http://examples.org" xmlns:ns1="http://example.org/types"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://example.org/types"/>
<xs:element name="AccountWSService" type="ns1:accountEMRIO"/>
</xs:schema>
<xs:schema version="1.0" targetNamespace="http://example.org/types" xmlns:ns1="http://examples.org"
xmlns:tns="http://example.org/types" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://examples.org"/>
<xs:complexType name="queryPageOutput">
<xs:sequence>
<xs:element name="fSiebelMessage" type="tns:accountEMRIO" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="accountEMRIO">
<xs:sequence>
<xs:element name="fIntObjectFormat" type="xs:string" minOccurs="0"/>
<xs:element name="fMessageType" type="xs:string" minOccurs="0"/>
<xs:element name="fMessageId" type="xs:string" minOccurs="0"/>
<xs:element name="fIntObjectName" type="xs:string" minOccurs="0"/>
<xs:element name="fOutputIntObjectName" type="xs:string" minOccurs="0"/>
<xs:element name="fintObjInst" type="xs:anyType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="queryPageInput">
<xs:sequence>
<xs:element name="fPageSize" type="xs:string" minOccurs="0"/>
<xs:element name="fSiebelMessage" type="tns:accountEMRIO" minOccurs="0"/>
<xs:element name="fStartRowNum" type="xs:string" minOccurs="0"/>
<xs:element name="fViewMode" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.org" xmlns:ns1="http://example.org/types">
<import namespace="http://example.org/types"/>
<xsd:complexType name="AccountQue">
<xsd:sequence>
<xsd:element name="arg0" type="ns1:queryPageInput"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="AccountQue" type="tns:AccountQue"/>
<xsd:complexType name="AccountQueResponse">
<xsd:sequence>
<xsd:element name="return" type="ns1:queryPageOutput"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="AccountQueResponse" type="tns:AccountQueResponse"/>
</schema>
</wsdl:types>
<wsdl:message name="AccountQueInput">
<wsdl:part name="parameters" element="tns:AccountQue"/>
</wsdl:message>
<wsdl:message name="AccountQueOutput">
<wsdl:part name="parameters" element="tns:AccountQueResponse"/>
</wsdl:message>
<wsdl:portType name="SimpleService">
<wsdl:operation name="AccountQue">
<wsdl:input message="tns:AccountQueInput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
ns1:Action=""/>
<wsdl:output message="tns:AccountQueOutput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
ns1:Action=""/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceSoapHttp" type="tns:SimpleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="AccountQue">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleService">
<wsdl:port name="SimpleServicePort" binding="tns:SimpleServiceSoapHttp">
<soap:address location="http://localhost:7101/WS-Project1-context-root/SimpleServicePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
In the above wsdl the collection of fintObjInst if of type xs:anytype. From the wsdl, I do not see the xsd mapping for AccountIC which includes Name and Desc. Due to which, when invoking the web service from a different client like c#(by creating proxy business service), I am unable to set the parameters for AccountIC. I am using JAX-WS stack and WLS 10.3. I have already looked at blog http://weblogs.java.net/blog/kohlert/archive/2006/10/jaxws_and_type.html but unable to solve this issue. However, at run time using a tool like SoapUI, when this wsdl is imported, I am able to see all the params related to AccountIC class.
Can some one help me with this.
Thanks,
Sudha.Did you try adding the the XmlSeeAlso annotation to the webservice
@XmlSeeAlso({<package.name>.AccountIC.class})
This will add the schema for the data type (AccountIC) to the WSDL.
Hope this helps.
-Ajay -
Error in conditional map using User Defined Function
All,
In my mapping I basically have a user defined function that returns the filename of my inbound file from the adapter-specific message attributes (file adapter). I know this is coded properly because if I simply assign this function to my destination field I can see the filename in the payload XML.
However if I conditionally check that returned value using if,then,else I get an error message stating:
"During the application mapping com/sap/xi/tf/_MaterialData2ZcustProdMastMulti_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformation"
Essentially in my if I'm checking if the value returned by my user defined function is equal to the constant "SOMECONSTANT" then I'm setting my destination field to some other constant value. Otherwise it's equal to a different constant value.
Any thoughts?Claus,
Thanks for the help. I actually had figured the problem out on my own. Sorry for not updating the thread sooner. What happened was this (as I suspected it wasn't related to my user defined function). For the newbies out there (of which I'm one) the problem was I was comparing strings in the graphical mapping tool using the Boolean "EQUALS" rather than the Text "EQUALSS".
Can you give yourself points for solving -
Using user-defined data types in Forms 6i
When I use the following code in Oracle Forms 6i
PROCEDURE test IS
prcl prcl_ty;
BEGIN
prcl := prcl.setParcel('xxx-xx-xxxx');
END;
I get 'Error 801'. However the above does work in SQL editor. The online help says PL/SQL8 client-side program units cannot support Oracle 8 object-related functionality and I suspect this is the reason I get the error from Forms. Is there a work-around for this.
The TYPE is defined as:
CREATE OR REPLACE
TYPE PRCL_TY AS OBJECT
(parcel VARCHAR2(11),
MEMBER FUNCTION getBook RETURN VARCHAR2,
MEMBER FUNCTION getMap RETURN VARCHAR2,
MEMBER FUNCTION getItem RETURN VARCHAR2,
MEMBER FUNCTION getItem_NS RETURN VARCHAR2,
MEMBER FUNCTION getSplit RETURN VARCHAR2,
MEMBER FUNCTION find RETURN VARCHAR2,
MEMBER FUNCTION find (yr in VARCHAR2) RETURN VARCHAR2,
MEMBER FUNCTION isValid RETURN BOOLEAN,
MEMBER FUNCTION toString RETURN VARCHAR2,
MEMBER FUNCTION toString (par IN VARCHAR2) RETURN VARCHAR2,
STATIC FUNCTION setParcel (istr IN VARCHAR2 DEFAULT '000-00-000A') RETURN prcl_ty) -- to be used as a constructor
NOT FINAL
CREATE OR REPLACE
TYPE BODY PRCL_TY AS
MEMBER FUNCTION getBook RETURN VARCHAR2 IS
BEGIN
return substr(self.parcel,1,3);
END;
MEMBER FUNCTION getMap RETURN VARCHAR2 IS
BEGIN
return substr(self.parcel,4,2);
END;
MEMBER FUNCTION getItem RETURN VARCHAR2 IS
BEGIN
return substr(self.parcel,6);
END;
MEMBER FUNCTION getItem_NS RETURN VARCHAR2 IS
BEGIN
return substr(self.parcel,6,3);
END;
MEMBER FUNCTION getSplit RETURN VARCHAR2 IS
BEGIN
return substr(self.parcel,9,1);
END;
MEMBER FUNCTION find RETURN VARCHAR2 IS
found varchar2(1);
BEGIN
begin
select 'x'
into found
from casrp
where cp_book_num = self.getBook
and cp_map_num = self.getMap
and cp_item_num = self.getItem
and rownum = 1;
return 'CASRP';
exception
when NO_DATA_FOUND then
begin
select 'x'
into found
from pro_prop
where pp_book_num = self.getBook
and pp_map_num = self.getMap
and pp_item_num = self.getItem
and rownum = 1
and NOT EXISTS (select 'x'
from cncl_prcl
where cr_book_num = self.getBook
and cr_book_num = self.getMap
and cr_book_num = self.getItem
and rownum = 1);
return 'PRO_PROP';
exception
when NO_DATA_FOUND then
return '';
end;
end;
END;
MEMBER FUNCTION find (yr IN VARCHAR2) RETURN VARCHAR2 IS
found varchar2(1);
BEGIN
begin
select 'x'
into found
from casrp
where cp_book_num = self.getBook
and cp_map_num = self.getMap
and cp_item_num = self.getItem
and cp_tax_yr = yr
and rownum = 1;
return 'CASRP';
exception
when NO_DATA_FOUND then
begin
select 'x'
into found
from pro_prop
where pp_book_num = self.getBook
and pp_map_num = self.getMap
and pp_item_num = self.getItem
and pp_tax_yr = yr
and rownum = 1
and NOT EXISTS (select 'x'
from cncl_prcl
where cr_book_num = self.getBook
and cr_book_num = self.getMap
and cr_book_num = self.getItem
and cr_tax_yr = yr
and rownum = 1);
return 'PRO_PROP';
exception
when NO_DATA_FOUND then
return '';
end;
end;
END;
MEMBER FUNCTION isValid RETURN BOOLEAN IS
i number;
BEGIN
for i in 1..8 loop
if substr(parcel,i,1) not between '0' and '9' then
return FALSE;
end if;
end loop;
if nvl(substr(parcel,9,1),'#') not between 'A' and 'Z' and
nvl(substr(parcel,9,1),'#') != '#' then
return FALSE;
end if;
return TRUE;
END;
MEMBER FUNCTION toString RETURN VARCHAR2 IS
BEGIN
return self.toString('-');
END;
MEMBER FUNCTION toString (par IN VARCHAR2) RETURN VARCHAR2 IS
BEGIN
return self.getBook||par|| self.getMap||par|| self.getItem;
END;
STATIC FUNCTION setParcel (istr IN VARCHAR2 DEFAULT '000-00-000A') RETURN prcl_ty IS
len number;
pos number;
lastch varchar2(1);
temp varchar2(30);
invalid_format exception;
pragma exception_init(invalid_format,-9001);
BEGIN
temp := upper(istr);
-- Find 1st occurance of '-'. If not in correct postion, pad book num with zeros.
pos := instr(temp,'-',1,1);
if pos > 0 then
if pos != 4 then
temp := lpad(substr(temp,1,pos-1),3,'0')||substr(temp,pos);
end if;
-- Find 2nd occurance of '-'. If not in correct postion, pad map num with zeros.
pos := instr(temp,'-',1,2);
if pos != 7 then
temp := substr(temp,1,4)||lpad(substr(temp,5,1),2,'0')||substr(temp,pos);
end if;
-- Pad item num
len := length(temp);
lastch := substr(temp,len);
temp := substr(temp,1,7)||lpad(substr(temp,8,len-1),3,'0');
if lastch between 'A' and 'Z' then
temp := temp||lastch;
end if;
end if;
temp := replace(temp,'-','');
if prcl_ty(temp).isValid then
return (prcl_ty(temp));
else
raise invalid_format;
end if;
END;
END;
Rich Hall
[email protected]You are correct in your assumptions. Client side PLSQL does not support user defined types like the one you are trying to use.
There are no workarounds I am afraid. -
How to pop-up a text box for a grid item on a user defined table?
Hello,
I have a user defined table with a grid & one of the columns is for comments. What I'm trying to do is to pop up a text box when double clicking in the column field. This would be the same as the Item Details column in the Sales Order ittems grid.
Thanks,
RonPlease post your question on SDK forum. Only SDK could meet your need.
Thanks,
Gordon -
Adding user-defined number of text fields.
Okay I am having problems, obviously. I am developing a program where the user will enter X and Y values and the program will calculate the relational data. However, I can't even get a start.
First of all, the user defines the number of pairs of points they want to define. For example, they have 20 points, each with its own X and Y, so they click on 20 and then okay in the first window.
The next window will then take their answer and display X and Y text fields for as many points as they defined. However, I can't figure out any way to do this.
Feel free to run the program, the problem lies in the method setTextFields(). Help please!
import javax.swing.*; //FOR SWING COMPONENT CLASSES
import java.awt.*; //FOR CONTAINER CLASS
import java.awt.event.*; //FOR EVENT HANDLING
public class RegressInput extends JFrame
private JComboBox listJComboBox; //COMBO BOX TO HOLD HOW MANY PAIRS OF DATA POINTS THE USER HAS TO ENTER
private JButton answerButton; //BUTTON TO CLICK AFTER SELECTING PAIRS OF DATA POINTS
private JPanel textFieldTopPanel; //TEXT FIELD TOP PANEL
private JPanel textFieldBottomPanel; //TEXT FIELD BOTTOM PANEL
private JPanel textFieldPanel; //TEXT FIELD PANEL
private CardLayout cardSelector; //DECLARE CARD LAYOUT OBJECT
private JPanel cardDeck; //DECLARE CARD PANEL OBJECT
public RegressInput(String title)
super(title); //CALL SUPERCLASS CONSTRUCTOR
//CREATE A CONTAINER
Container container = getContentPane();
//INSTANTIATE CARD LAYOUT OBJECT
cardSelector = new CardLayout();
//INSTANTIATE PANEL OBJECT
cardDeck = new JPanel();
//SET LAYOUT OF CARD DECK PANEL TO CARD LAYOUT
cardDeck.setLayout(cardSelector);
//DEFINE LABEL FOR FIRST CARD
Label question = new Label("How many PAIRS of data would you like to enter?");
//BUTTON TO SUBMIT NUMBER OF POINTS TO PLOT
answerButton = new JButton("OK");
listJComboBox = new JComboBox( getArray() );//USE getArray() METHOD TO SET ITEM LIST OF THE COMBO BOX
listJComboBox.setMaximumRowCount(10); //SETS THE VISIBLE NUMBER OF ITEMS TO THE USER
Label xValues = new Label("X Values"); //LABEL FOR X values
Label yValues = new Label("Y Values"); //LABEL FOR Y values
//BUILD CARD DECK
JPanel comboBoxCard = new JPanel(); //CREATE FIRST CARD
comboBoxCard.add(question); //ADD question LABEL TO FIRST CARD
comboBoxCard.add(listJComboBox); //ADD listJComboBox TO FIRST CARD
comboBoxCard.add(answerButton); //ADD answerButton TO FIRST CARD
textFieldTopPanel = new JPanel(); //CREATE TOP PANEL OF SECOND CARD
textFieldTopPanel.add(xValues); //ADD xValues Label TO SECOND CARD
textFieldTopPanel.add(yValues); //ADD yValues Label TO SECOND CARD
textFieldBottomPanel = new JPanel(); //CREATE BOTTOM PANEL OF SECOND CARD
textFieldBottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10)); //SET LAYOUT FOR BOTTOM PANEL
textFieldPanel = new JPanel(); //CREATE PANEL FOR SECOND CARD
textFieldPanel.setLayout(new BorderLayout(10, 10)); //SET LAYOUT FOR SECOND CARD
textFieldPanel.add(textFieldTopPanel, "North"); //ADD textFieldTopPanel TO NORTH
textFieldPanel.add(textFieldBottomPanel, "South"); //ADD textFieldBottomPanel TO SOUTH
cardDeck.add(comboBoxCard, "Step 1"); //ADD FIRST CARD TO DECK
cardDeck.add(textFieldPanel, "Step 2"); //ADD SECOND CARD TO DECK
container.add(cardDeck); //ADD CARD DECK TO CONTAINER
//DEFINE BUTTON HANDLER OBJECT
ButtonHandler buttonHandler = new ButtonHandler();
//ADD ACTION LISTENER FOR BUTTONS
answerButton.addActionListener(new ButtonHandler());
}//END RegressInput() CONSTRUCTOR
//METHOD TO CREATE AND RETURN AN ARRAY OF VALUES FOR JComboBox
private String[] getArray()
//CREATE ARRAY TO HOLD 30 VALUES
int numbers[] = new int[29];
//CREATE int IN ORDER TO START THE ARRAY AT 2 INSTEAD OF 1
int number = 2;
//ASSIGN VALUES FROM 2 TO 30 TO numbers[] ARRAY
for(int count=0; count < 29; ++count)
numbers[count] = number; //SETS EACH INDEX TO number
number++; //INCREMENTS number
}//END for LOOP
//CREATE pairs[] ARRAY TO HOLD 30 STRINGS
String pairs[] = new String[29];
//ASSIGN VALUES 1 TO 30 IN STRING ARRAY FOR COMBO BOX
for(int count = 0; count < 29; ++count)
pairs[count] = "" + numbers[count];
}//END for LOOP
return pairs;//RETURNS pairs[] ARRAY FOR THE LIST ITEMS IN listJComboBox
}//END getArray() METHOD8
//RETURNS THE ITEM SELECTED BY THE USER FROM THE JComboBox
private int getValue()
//ASSIGNS STRING VALUE OF THE JComboBox TO A WRAPPER
Integer v = new Integer((String) listJComboBox.getSelectedItem());
//ASSIGNS WRAPPER VALUE TO int
int value = v.intValue();
//RETURN VALUE OF SELECTED ITEM
return value;
}//END getValue()
private void setTextFields()
{//HERE LIES THE PROBLEM! WHAT GOES IN THIS METHOD????
for(int count = 0; count < (2 * getValue()); ++count)
}//END setTextFields()
//BUTTON EVENT HANDLER CLASS
private class ButtonHandler implements ActionListener
//PROCESS EVENT
public void actionPerformed(ActionEvent e)
//WHICH BUTTON CAUSED THE EVENT?
if(e.getSource() == answerButton)
cardSelector.last(cardDeck);
cardDeck.setSize(600,600);
}//END if STATEMENT
}//END actionPerformed()
}//END ButtonHandler CLASS
}//END RegressInput CLASSHere is main:
import javax.swing.JFrame;
public class TestSharpStats
public static void main(String[] args)
//DEFINE FRAME OBJECT
RegressInput window = new RegressInput("Hi"); //SETS TITLE BAR
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //CLOSES WINDOW
window.setSize(400, 600); //SET FRAME SIZE
window.setResizable(true); //PREVENTS USER FROM RESIZING WINDOW
window.setVisible(true); //SETS window TO VISIBLE
}//END main()
}//END TestSharpStats CLASSmuit-post: http://forum.java.sun.com/thread.jspa?messageID=4442652
-
How to let the user define the colors for each plots in the graph (I use LabVIEW 7)?
How to let the user define the colors for each plots in the graph (I
use LabVIEW 7)?Hi,
Take a look at this example, it uses property nodes to select tha
active plot and then changes the color of that plot.
If you want to make the number of plots dynamic you could use a for
loop and an array of color boxes.
I hope this helps.
Regards,
Juan Carlos
N.I.
Attachments:
Changing_plot_color.vi 38 KB -
How do you use user defined error messages in Value Help?
Hi,
I'm currently working on a Modifiable Value Help Selector in Web Dynpro Java, and I want to use a user defined error message when I validate the values entered by a user. Currently, it's returning its default error message ("Character <string> does not match...").
Since the project requires a different error message, is there a way to override the default error message and use my defined error message instead?
Thanks!Hi Angelo,
I am not sure why message area is showing both Custom and inbuilt messages but you can try the following:
i guess you must be using reportContextAttribute exception for showing Error messages on the input fields as well.in that case you can disable the message area so messages will appear only on the Context level ie; on input fields.
For other messages apart from validation messages you can enable the message area before reporting the exception.
make sure the boolean context variable which will be used for enabling and disabling the message area should have Readonly property set as true.
I am not sure whether this is the only solution for this but you can try and see if it works.
Siddharth -
How to provide value to a User Defined field thru java code
I am using OIM 11.1.1.5.
I have a user defined field called Unique-Customer-Number. This field need to be pre-populated during user creation (using OIM Web UI) and the value comes from a java code.
Can any of you tell me the high level steps to implement this.
Thanks!
KabiThanks Rajiv,
I just followed everything on metalink 1262803.1. My console shows the followings during Metadata import.
weblogicImportMetadata.bat :-
Starting import metadata script ....
Please enter your username :weblogic
Please enter your password :
Please enter your server URL [t3://localhost:7001] :t3://10.10.99.99:7001
Connecting to t3://10.10.99.99:7001 with userid weblogic ...
Successfully connected to Admin Server 'adm_server01' that belongs to domain 'server01'.
Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port or Admin port should be used instead.
Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.For more help, use help(domainRuntime)
Disconnected from weblogic server: adm_eimsdv1s01
End of importing metadata script ...
Exiting WebLogic Scripting Tool.
How I will I know that my plugin/ event-Handler is registered successfully. Is there any screen where I can see all registered plugins ? -
Okay I am having problems, obviously. I am developing a program where the user will enter X and Y values and the program will calculate the relational data. However, I can't even get a start.
First of all, the user defines the number of pairs of points they want to define. For example, they have 20 points, each with its own X and Y, so they click on 30 and then okay in the first window.
The next window will then take their answer and display X and Y text fields for as many points as they defined. However, I can't figure out any way to do this.
Feel free to run the program, the problem lies in the method setTextFields(). Help please!
import javax.swing.*; //FOR SWING COMPONENT CLASSES
import java.awt.*; //FOR CONTAINER CLASS
import java.awt.event.*; //FOR EVENT HANDLING
public class RegressInput extends JFrame
private JComboBox listJComboBox; //COMBO BOX TO HOLD HOW MANY PAIRS OF DATA POINTS THE USER HAS TO ENTER
private JButton answerButton; //BUTTON TO CLICK AFTER SELECTING PAIRS OF DATA POINTS
private JPanel textFieldTopPanel; //TEXT FIELD TOP PANEL
private JPanel textFieldBottomPanel; //TEXT FIELD BOTTOM PANEL
private JPanel textFieldPanel; //TEXT FIELD PANEL
private CardLayout cardSelector; //DECLARE CARD LAYOUT OBJECT
private JPanel cardDeck; //DECLARE CARD PANEL OBJECT
public RegressInput(String title)
super(title); //CALL SUPERCLASS CONSTRUCTOR
//CREATE A CONTAINER
Container container = getContentPane();
//INSTANTIATE CARD LAYOUT OBJECT
cardSelector = new CardLayout();
//INSTANTIATE PANEL OBJECT
cardDeck = new JPanel();
//SET LAYOUT OF CARD DECK PANEL TO CARD LAYOUT
cardDeck.setLayout(cardSelector);
//DEFINE LABEL FOR FIRST CARD
Label question = new Label("How many PAIRS of data would you like to enter?");
//BUTTON TO SUBMIT NUMBER OF POINTS TO PLOT
answerButton = new JButton("OK");
listJComboBox = new JComboBox( getArray() );//USE getArray() METHOD TO SET ITEM LIST OF THE COMBO BOX
listJComboBox.setMaximumRowCount(10); //SETS THE VISIBLE NUMBER OF ITEMS TO THE USER
Label xValues = new Label("X Values"); //LABEL FOR X values
Label yValues = new Label("Y Values"); //LABEL FOR Y values
//BUILD CARD DECK
JPanel comboBoxCard = new JPanel(); //CREATE FIRST CARD
comboBoxCard.add(question); //ADD question LABEL TO FIRST CARD
comboBoxCard.add(listJComboBox); //ADD listJComboBox TO FIRST CARD
comboBoxCard.add(answerButton); //ADD answerButton TO FIRST CARD
textFieldTopPanel = new JPanel(); //CREATE TOP PANEL OF SECOND CARD
textFieldTopPanel.add(xValues); //ADD xValues Label TO SECOND CARD
textFieldTopPanel.add(yValues); //ADD yValues Label TO SECOND CARD
textFieldBottomPanel = new JPanel(); //CREATE BOTTOM PANEL OF SECOND CARD
textFieldBottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10)); //SET LAYOUT FOR BOTTOM PANEL
textFieldPanel = new JPanel(); //CREATE PANEL FOR SECOND CARD
textFieldPanel.setLayout(new BorderLayout(10, 10)); //SET LAYOUT FOR SECOND CARD
textFieldPanel.add(textFieldTopPanel, "North"); //ADD textFieldTopPanel TO NORTH
textFieldPanel.add(textFieldBottomPanel, "South"); //ADD textFieldBottomPanel TO SOUTH
cardDeck.add(comboBoxCard, "Step 1"); //ADD FIRST CARD TO DECK
cardDeck.add(textFieldPanel, "Step 2"); //ADD SECOND CARD TO DECK
container.add(cardDeck); //ADD CARD DECK TO CONTAINER
//DEFINE BUTTON HANDLER OBJECT
ButtonHandler buttonHandler = new ButtonHandler();
//ADD ACTION LISTENER FOR BUTTONS
answerButton.addActionListener(new ButtonHandler());
}//END RegressInput() CONSTRUCTOR
//METHOD TO CREATE AND RETURN AN ARRAY OF VALUES FOR JComboBox
private String[] getArray()
//CREATE ARRAY TO HOLD 30 VALUES
int numbers[] = new int[29];
//CREATE int IN ORDER TO START THE ARRAY AT 2 INSTEAD OF 1
int number = 2;
//ASSIGN VALUES FROM 2 TO 30 TO numbers[] ARRAY
for(int count=0; count < 29; ++count)
numbers[count] = number; //SETS EACH INDEX TO number
number++; //INCREMENTS number
}//END for LOOP
//CREATE pairs[] ARRAY TO HOLD 30 STRINGS
String pairs[] = new String[29];
//ASSIGN VALUES 1 TO 30 IN STRING ARRAY FOR COMBO BOX
for(int count = 0; count < 29; ++count)
pairs[count] = "" + numbers[count];
}//END for LOOP
return pairs;//RETURNS pairs[] ARRAY FOR THE LIST ITEMS IN listJComboBox
}//END getArray() METHOD8
//RETURNS THE ITEM SELECTED BY THE USER FROM THE JComboBox
private int getValue()
//ASSIGNS STRING VALUE OF THE JComboBox TO A WRAPPER
Integer v = new Integer((String) listJComboBox.getSelectedItem());
//ASSIGNS WRAPPER VALUE TO int
int value = v.intValue();
//RETURN VALUE OF SELECTED ITEM
return value;
}//END getValue()
private void setTextFields()
{//HERE LIES THE PROBLEM! WHAT GOES IN THIS METHOD????
for(int count = 0; count < (2 * getValue()); ++count)
}//END setTextFields()
//BUTTON EVENT HANDLER CLASS
private class ButtonHandler implements ActionListener
//PROCESS EVENT
public void actionPerformed(ActionEvent e)
//WHICH BUTTON CAUSED THE EVENT?
if(e.getSource() == answerButton)
cardSelector.last(cardDeck);
cardDeck.setSize(600,600);
}//END if STATEMENT
}//END actionPerformed()
}//END ButtonHandler CLASS
}//END RegressInput CLASS
Here is main:
import javax.swing.JFrame;
public class TestSharpStats
public static void main(String[] args)
//DEFINE FRAME OBJECT
RegressInput window = new RegressInput("Hi"); //SETS TITLE BAR
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //CLOSES WINDOW
window.setSize(400, 600); //SET FRAME SIZE
window.setResizable(true); //PREVENTS USER FROM RESIZING WINDOW
window.setVisible(true); //SETS window TO VISIBLE
}//END main()
}//END TestSharpStats CLASSIf your teacher taught you to program like this they should be shot. There is no need to comment every single line (especially in upper case). The comments stand out more that the code does and doesn't add any usefull information. Obviously comments are important, but you need to pick and choose when to use them.
Swing related questions should be posted in the Swing forum.
Also, don't use AWT components in a Swing application. Label is AWT. JLabel is Swing.
I would use a JTable to input the matching pairs of data. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Table to get started. -
User defined report with bind variable
How can I create an user defined report using a bind variable?
We currently do not support bind variables in User Defined Reports. We are looking at adding that function before production but I can't promise.
-- Sharon -
Confirmation of User defined fields on CO11N
Dear All,
Can anybody tell me how to confirm user defined field during operation confirmation of an order. I have created a user field key and assigned in the operation detail screen in routing. Is it required to include a freely defined screen for CO11N in customizing or any other setting is there.
Thanks in advance for your valuable inputs.
Regards,
Uday Parchure<b>Define Customer-Specific Detail Areas for Single Screen Entry</b>The following enhancement is available for production orders:
CONFPP07 define detail areas for single screen entry
With this enhancement you can define your own detail areas (screens), which can be issued for single screen entry of time ticket confirmations.
Enhancement CONFPP07 contains the following enhancement components:
Function module exits
EXIT_SAPLCORU_S_100 Transfer data from SAPLCORU_S to customer-defined screen
EXIT_SAPLCORU_S_101 Return data from customer-defined screen to SAPLCORU_S
Display documentation
Screen areas
Screen areas that you can define yourself are available.
Activities
1. Create the enhancement
To do so, create a new project, or use an existing project.
2. Activate the project.
Your enehancement only takes effect after you have activated it.
Further Notes
Enhancememnts, as opposed to modifications, are fundamentally independent of releases since they are not made in the SAP original, but in a name space that is reserved for customers.
you have to create a customer defined screen and attach as in the link. Add the Freely definable detail screen in OPK0. Confirm the user defined fields.
Regards
MSR
Message was edited by:
Soundararajan Murugesan
Message was edited by:
Soundararajan Murugesan -
User defined fields in Crystal layout
Hi All,
I want to add user defined field values in crystal layout for Sales order, but its not listed in RDR1 tables there but it's available in SAP query manager view. How can i get that in Crystal reports. please suggest on this.
Regards
SreeYou can then remove the key and the fields in the database will keep their correct definitions rather than varchar(max) which is causing the initial problems.
Adding extra keys may uause performance issues if you leave them there for a large table.
I have also had issues of varchar(max) fields causing database connection issues when running the reports in 8.81 PL07.
Rob -
Opening a Crystal Report in B1 8.8 in a User Defined Form representing UDO
Hi Experts,
Is it possible to open a Crystal Report from a User Defined Form representing my UDO?
I had developed a 'Vendor Quotation' UDO and its User Defined Form
I wanted to show the report while clicking the Preview menu in SAP B1 8.8 toolbar.
I have created the Crystal report and used the record selection as {@OVQT.DocEntry} = {DocKey@}
Please help
Also, is it possible to add Print layout and assign a default Print layout to this User Defined Form?
Thanks in advance
Regards
ArunHi,
I also face the same problem. I make a master type using UDO. But i want to print it.
In my opinion ( i haven't tried this way ). If we make a UDO ( master or document type ) , we will find the docentry and object field in our UDT. Both of these will connect between SAP form and Crystal report. In crystal report we select the tmsp_doclinetypelayout. It is a store procedure which will connect between SAP form and CR. Before that try to modify this SP by adding the udo object.
Fyi, if i'm not mistake dockey is connected to docentry SAP form.
Thanks
regards
bodhi86
Maybe you are looking for
-
Sub:Filtering is not working in ALV Grid
Hi All, I developed a new ALV report,where in the out put i can set filtering for other columns(ex:Date,Number),but i can'nt able to set Filtering for one of the column which is CHAR type. But when we went to table for this field filtering is working
-
How to send a numbers document to iTunes
I'm trying to send a document I worked on in numbers on my iPad to iTunes and I can't get it to show up on my computer. I'm not sure if I have to sync my iPad for it to update the document or not. I would like to do it wireless that way I can have th
-
Only getting context menus- can't select an item?
I spilled some tea on my Macbook Pro key board- cleaned it up and dried it out. Now whenever I try to select an item (mac mail, numbers, finder) only get a context menu. Can't select an item or type. Mac mail can only look at one of my mail boxes c
-
ABAP Web dynpro Interactive forms ADOBE
Hi, I want to create Adobe form for quotation. There are item groups and within item group there are sub items. After displaying all sub items for a group i want to show Total amount. This is repeated for every group. Can anyone help me out with this
-
?