Get the value of Container element in message mapping
Hi,
Is it possible to read the value of container elements(bpm) in a UDF defined in message mapping. If yes, please tell me how?
Thanks and regards,
Siji
Siji,
Refer thread - Creating the container Object In Java Mapping
Regards,
Geetha
Similar Messages
-
How to get the values of all elements and sub elements from following xml
how to get the values of all elements and sub elements from following xml...
<?xml version="1.0" encoding="UTF-8" ?>
<List_AML_Finacle xmlns="http://3i-infotech.com/Cust_AML_Finacle.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://3i-infotech.com/Cust_AML_Finacle.xsd List_AML_Finacle.xsd">
<TransactionID>TransactionID</TransactionID>
<Match>
<Src_Matched_Field>Src_Matched_Field</Src_Matched_Field>
<List_Matched_Field>
<FSFM_Matches>
<NUMBER>NUMBER</NUMBER>
<TERROR>TERROR</TERROR>
<TU>TU</TU>
<NAMEU>NAMEU</NAMEU>
<DESCRIPT>DESCRIPT</DESCRIPT>
<KODCR>KODCR</KODCR>
<KODCN>KODCN</KODCN>
<AMR>AMR</AMR>
<ADDRESS>ADDRESS</ADDRESS>
<SD>SD</SD>
<RG>RG</RG>
<ND>ND</ND>
<VD>VD</VD>
<GR>GR</GR>
<YR>YR</YR>
<MR>MR</MR>
<CB_DATE>CB_DATE</CB_DATE>
<CE_DATE>CE_DATE</CE_DATE>
<DIRECTOR>DIRECTOR</DIRECTOR>
<FOUNDER>FOUNDER</FOUNDER>
<TERRTYPE>TERRTYPE</TERRTYPE>
</FSFM_Matches>
<OfacMatchDetails>
<UID>UID</UID>
<TITLE>TITLE</TITLE>
<SDNTYPE>SDNTYPE</SDNTYPE>
<REMARKS>REMARKS</REMARKS>
<ID_UID>ID_UID</ID_UID>
<IDTYPE>IDTYPE</IDTYPE>
<IDNUMBER>IDNUMBER</IDNUMBER>
<IDCOUNTRY>IDCOUNTRY</IDCOUNTRY>
<ISSUEDATE>ISSUEDATE</ISSUEDATE>
<EXPIRATIONDATE>EXPIRATIONDATE</EXPIRATIONDATE>
<ADDRESS1>ADDRESS1</ADDRESS1>
<ADDRESS2>ADDRESS2</ADDRESS2>
<ADDRESS3>ADDRESS3</ADDRESS3>
<CITY>CITY</CITY>
<STATEORPROVINCE>STATEORPROVINCE</STATEORPROVINCE>
<POSTALCODE>POSTALCODE</POSTALCODE>
<COUNTRY>COUNTRY</COUNTRY>
</OfacMatchDetails>
</List_Matched_Field>
</Match>
</List_AML_Finacle>avoid multi post
http://forum.java.sun.com/thread.jspa?threadID=5249519 -
How do you get the value of an ELEMENT node?
Which API call do you use to get the value of a simple element node, e.g. <element>value</element>
The comments for getNodeValue in the header file oraxml.h says
This function returns the "value" (e.g. associated data) for the given node. Only COMMENT, CDATA and TEXT nodes have data, all others return NULL.
I've used an xpath expression to select the node that I want but now I can't get the value of the node because it is of type ELEMENT.
When use getNodeValue I get NULL just like the comment says. Not sure what to try next.For parsing with XPath
http://www.oracle.com/technology/pub/notes/technote_domparser.html -
Getting the value of an element using the attribute value
I have a Document object and I want to get the value from the element that has an attribute value of "college". Does that make sense?
<TEAM>
<FIELD name="city">Phoenix</FIELD>
<SECTION name="NASH">
<FIELD name="college">Santa Clara</FIELD>
<FIELD name="grad">1997</FIELD>
<FIELD name="years">9</FIELD>
<FIELD name="PPG">19.2</FIELD>
<FIELD name="AST">10.4</FIELD>
<FIELD name="REB">4.2</FIELD>
</SECTION>
</TEAM>
Thanks!I have a Document object and I want to get thevalue
from the element that has an attribute value of
"college". Does that make sense?
<TEAM>
<FIELD name="city">Phoenix</FIELD>
<SECTION name="NASH">
<FIELD name="college">Santa
FIELD name="college">Santa Clara</FIELD>
<FIELD
<FIELD name="grad">1997</FIELD>
<FIELD
<FIELD name="years">9</FIELD>
<FIELD
<FIELD name="PPG">19.2</FIELD>
<FIELD
<FIELD name="AST">10.4</FIELD>
<FIELD
<FIELD name="REB">4.2</FIELD>
</SECTION>
</TEAM>
Thanks!
/TEAM/SECTION/FIELD[@name='college']
if you just want the text then:
/TEAM/SECTION/FIELD[@name='college']/text() -
How to set/get the values thru Wedbynpro coding for User mapping fields
Hi All
In system object we have the user mapping fields like District,city,plant,Salesmanager.
now we want to set/get the values of these usermapping fields of system object thru webdynpro coding...
if anybody have sample codes of the same then it would be great help to me
Thanks in advance
Thanks
Trisha RaniHi Kavitha
Thanks for your reply
My requirement is exactly as follows.
1) i have created one portal system object in system administration and also i created usermapping fields in the system object from the usermanagement in system object.
i created the user mapping fields like Plant,SalesManager,District etc.
i also created the system alias name for the same system object
2) Now i came to persoanlize link and mapped the system object to the portal user.
while mapping to the system object we need to enter Mapping userId, Password , once we enter these values and we can also enter the values of usermapping fields which we defined while creating the system object ( for example District,Salesmanager,Plant etc)
once we enter all the values and click on save then these usermapping values to be mapped to the portal user.
3) Now my requirement is , i want to control the usermapping field values thru webdynpro coding for setting/getting the values.
I need sample code of the same.
Please let me know if u need more details on the same.
Thanks
Trisha Rani -
Object - MLST_NETW container not getting the values?
Hi,
I created a custom FM for the object - MLST_NETW and event STARTED
and in the workflow container I created Element for this object - by selecting Obect type - MLST_NETW
Now the problem is - When we do status change in tcode - CJ20N it is triggering the custom worklfow but in the worklfow container it is not getting any values. Container fields are empty. I need to get the project defination field value to the workflow.
Can any one tell me what could be wrong?
Thanks in advance.
M.Hi Murali,
Yes. Binding for event to workflow not defined.
For that, press Ctrl + F8 in the workflow template then it will take you to verision dependent tab. There you can find the start events tab.
Here only you entered the Business object and event. Right? So there one button is there for binding. CLick on it and check whether event to workflow binding has done or not.
Event container EVT_OBJTYPE should binded with your workflow business object.
Thanks. -
How to get the values from a html form embedded in a swing container
Hi all,
I am developing an application in which i have to read a html file and display it in a swing container.That task i made it with the help of a tool.But now i want to get the values from that page.ie when the submit button is clicked all the values of that form should be retrived by a servlet/standalone application.I don't know how to proceed further.Any help in this regard will be very greatful
Thanks in advance,
PrakashBy parsing the HTML.
-
How to get the values multiple times for the specified element - ABAP IXML.
Hi all,
i have requirement to get the values for the specified elements multiple times. eg:., if the element is used in the xml 4 times then i need to get all the 4 values. here is the sample xml,
<View mmRelease="6.30" mmVersion="2.0" mmTimestamp="1180099591892" name="Comp_viewtestView" package="sap.com" masterLanguage="en">
<AbstractView.InboundPlugs>
<InboundPlug name="ip2">
<ParameterizedFeature.Parameters>
<Parameter name="ippara2">
<Parameter.Type>
<Core.ForeignReference modelName="DtDictionary" package="com.sap.dictionary" name="binary" type="DtSimpleType"/>
</Parameter.Type>
</Parameter>
</ParameterizedFeature.Parameters>
</InboundPlug>
<InboundPlug name="hi">
<ParameterizedFeature.Parameters>
<Parameter name="hipara">
<Parameter.Type>
<Core.ForeignReference modelName="DtDictionary" package="com.sap.ide.webdynpro.uielementdefinitions" name="Visibility" type="DtSimpleType"/>
</Parameter.Type>
</Parameter>
</ParameterizedFeature.Parameters>
</InboundPlug>
Here i need to store the following values in internal table, the element to get the values are,
(1) InboungPlug name and the respective values of "Parameter name" and "Parameter type" name value.
The output will be of 2 records & values should be
Inbound plug name = ip2
Parameter name = ippara2
Parameter type = binary
2nd record
Inbound plug name = hi
Parameter name = hipara
Parameter type = Visibility
These 2 records should be in internal table and then i will be passing to database table...
Can anyone provide me the code for the above......
Thanks in advance,
Vishnu.I didn't get ur requirement..
As per my understanding, upload the XML file into an internal table and then loop over the internal table and get the values for ptype and pname..
XML ABAP - may b helpfull
Edited by: Veeranji Reddy on May 7, 2009 2:10 PM -
Get the value from a selected row in a table
Hi all,
My table contains a tree structure.
When I select a single row, I need to get the value of a particular column.
I created an action on the leadSelect of the table and gave the following code:
public void onActionleadValue(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionleadValue(ServerEvent)
String strLeadValue = wdContext.nodeAttribute_View_Out().currentAttribute_View_OutElement().getAttributeAsText("<MyModelAttributename>");
wdComponentAPI.getMessageManager().reportSuccess("selected lead value "+strLeadValue);
wdContext.currentContextElement().setLeadselectedvalue(strLeadValue);
//@@end
My Bapi returns me 6 records. and when I click on any row its always pointing to the last record value.
What could be the problem?
Thanks
AnjanaHi Anjana,
Try this.
try
IWDMessageManager msg = wdComponentAPI.getMessageManager();
int leadselect = wdContext.nodeSChild1().getLeadSelection();
for(int i=0;i<wdContext.nodeSChild1().size();i++)
if(leadselect == i)
//Displaying output in diff table
// IPublicTestComp.ITableNodeElement tabelm = wdContext.createTableNodeElement();
// tabelm.setAttribute1(wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute1());
// tabelm.setAttribute2(wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute2());
// tabelm.setAttribute3(wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute3());
// wdContext.nodeTableNode().addElement(tabelm);
String att1 = wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute1();
String att2 = wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute2();
String att3 = wdContext.nodeSChild1().getSChild1ElementAt(i).getAttribute3();
msg.reportSuccess("Row ("i") : "att1"====="att2"======"+att3);
} catch (WDDynamicRFCExecuteException e) {
wdComponentAPI.getMessageManager().reportException("Message : "+ e.getMessage(),true);
Regards,
Mithu -
How to get the value from a database without submitting a jsp page
I have a jsp which has a text box depending on the value entered I want to get the value from a database for other two fields with out submitting jsp page. I am using struts.
Thanks For any assistance provided.Alright,here is an example for you for the first case.
Present.jsp:
============
<html:html>
<head>
<title><html:message key="page.title"/></title>
</head>
<body>
<html:form action="ChangeEvent.do">
<html:hidden property="method"/>
<!-- Submitting the Form onKeyUp of EmpId field and trying to save the
state of the Form in the scope of session -->
Emp Id:<html:text property="empId" size="5" onkeyup="if(true){this.form.elements[0].value='populateDetails';this.form.submit();}"/>
Emp Name:<html:text property="empName" size="10" />
Email Address:<html:text property="email" size="10" />
<html:submit>Submit</html:submit>
</html:form>
</body>
</html:html>struts-config.xml:
==================
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- Form bean which stores the properties of all the Form elements -->
<form-beans>
<form-bean name="employeeFormBean" type="org.apache.struts.action.DynaActionForm">
<form-property name="empId" type="java.lang.String"/>
<form-property name="empName" type="java.lang.String"/>
<form-property name="email" type="java.lang.String" />
</form-bean>
</form-bean>
<action-mappings>
<action path="/ChangeEvent" type="Test.GetChangeAction" name="employeeFormBean" scope="request" parameter="method">
<!-- On successful call of DB the Page has to be forwarded to the same page again by
uploading updated form bean values. -->
<forward name="success" path="/Present.jsp"></forward>
<forward name="failed" path="/error.jsp"></forward>
</action>
</action-mappings>
</struts-config>GetChangeAction.java:
=====================
public class GetChangeAction extends DispatchAction{
public ActionForward populateDetails(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
DynaActionForm dForm = (DynaActionForm)form;
String empId = dForm.get("empId");
// calling Model / Db and then getting back Employee Details
EmployeeBean eb = ModelUtils.getDetails(empId);
// Updating form bean by updating values from the Model
dForm.set("empName".eb.getEmpName());
dForm.set("email".eb.getEmail());
return mapping.findForward("success");
}well to me this should work regardless to any browser but we need to make sure we put in our logic properly. -
How to get the values returned by a function in a drop down?
Hi All,
Can anyone please help in getting the values returned by a function into a drop down? I have a java class file where in i have written a function called getWeeks() which give all the week dates and i want to display these week dates in a drop down box in a JSP page.
Please help me in this regard.
Thanks in Advance!!
Lakshman.Hi Lakshman,
the following code can help you do what you want :
<hbj:dropdownListBox id="calendar" tooltip="Calendar" selection="<%= selected %>">
<%
String[] weeks = myObjectBean.getWeeks();
for (int i = 0; i < weeks.length; i++) {
%>
<hbj:listBoxItem key="<%= i %>" value="<%= weeks<i> %>"/>
<%
%>
</hbj: dropdownListBox>
The <%= selected %> snippet allows you to pre-select one of the options (provided that the variable 'selected' is equal to one of the listBoxItem keys).
You can also add onSelect to the tag (e.g. = "setSelectedItem"). It corresponds to a method in the corresponding JSPDynPage class. This means that when you select another item in the dropdown list, the method in your Java class is performed (allowing you to save the selected value and performing actions with it)
I hope this helped you enough,
kind regards,
Frederic
Edited seven times by: Frederic Taes on Nov 5, 2008 11:24 AM -> the onSelect element was in the hbj tag and in the text with "='setSelectedItem'" next to it and when I tried to post my message, I got a 501 error all the time ! Seems like a SDN bug to me ... -
Dom4j -- getting the value of an ancestor's sibling
Hi,
starting to work with dom4j, and trying to get the value of an ancestor element's sibling. The thing is, the element I'm matching can appear at several levels of the document.
so, if I have a node, and it's getPath() value is something like:
/root/element1/element2/element3/myElement,
and for every "myElement" match I make, I want to get the element1/title value,
what is the best way to do that? Also, sometimes myElement might be under element3, or element6, or somewhere in between.
I tried this, but got a null pointer exception:
while (i.hasNext()){
Node n = (Node) i.next();
if (n.getPath().contains("element1")){
Node n2 = (Node) n.getParent();
boolean match = false;
while (match==false) {
if (n2.getName().equals("element1")) {
Node form = (Node) n2;
log.logwrite("match made: " + form.getName() + ": "
+ form.getText());
match = true;
} else {
n2 = n2.getParent();
}thanks,
bp
Edited by: badperson on Nov 30, 2007 1:41 PM
Edited by: badperson on Nov 30, 2007 1:43 PMThat sort of looks okay to me. Which line of code throws the exception?
-
Getting the Values from a Tiled View
Hi,
I have a TiledView and I have checkbox in the tiled view. I am trying
to get the values of the checked boxes.
I have coded like this.
Object[] links = getRSystemLinks().getCbSystemUrl().getValues();
if I see the links.length i get only one. In html If I see the code
it appends the TileIndex in brackets. If I replace the TileIndex with
0 in all the fields in endCbSystemUrl method I get the correct values.
In the TiledView beginDisplay() method my code is like this.
if (getPrimaryModel() == null) throw new ModelControlException
("Primary model is null");
super.beginDisplay();
resetTileIndex();
pgCustomizeLinksViewBean parentBean = (pgCustomizeLinksViewBean)
getParent();
((DatasetModel) getDefaultModel()).setSize
(parentBean.SystemChoicesValue.size());
Any Suggestions on this.
Thanks
NamburiNamburi--
Remember, the getValues() method does not return the values from a column in
a TiledView. It is strictly for use by fields that can have multiple
values, like multi-select list boxes.
DO NOT remove the indexing feature from the field names, especially in the
case of checkboxes, because checkboxes aren't submitted back to the server
unless they are checked. By overriding the automatic checkbox tracking
feature JATO provides, you won't be able to tell which checkboxes were
actually checked by row--you'll simply get back a list the same size as the
number of checkboxes that were checked, without any placeholders for the
ones that weren't checked.
Instead, on submit, you simply need to move through the tiledView and check
the value of checkbox on each row:
tiledView.beforeFirst();
while (tiledView.next())
if (getDisplayFieldBooleanValue("myCheckBox"))
You can use the same construct to build up an array or list:
List checkedList=new LinkedList();
tiledView.beforeFirst();
while (tiledView.next())
if (getDisplayFieldBooleanValue("myCheckBox"))
checkedList.add(new Boolean(true))
else
checkedList.add(new Boolean(false))
Todd
Todd Fast
Senior Engineer
Sun Microsystems, Inc.
todd.fast@s...
----- Original Message -----
From: <vnamboori@y...>
Sent: Wednesday, October 17, 2001 3:49 PM
Subject: [iPlanet-JATO] Getting the Values from a Tiled View
Hi,
I have a TiledView and I have checkbox in the tiled view. I am trying
to get the values of the checked boxes.
I have coded like this.
Object[] links = getRSystemLinks().getCbSystemUrl().getValues();
if I see the links.length i get only one. In html If I see the code
it appends the TileIndex in brackets. If I replace the TileIndex with
0 in all the fields in endCbSystemUrl method I get the correct values.
In the TiledView beginDisplay() method my code is like this.
if (getPrimaryModel() == null) throw new ModelControlException
("Primary model is null");
super.beginDisplay();
resetTileIndex();
pgCustomizeLinksViewBean parentBean = (pgCustomizeLinksViewBean)
getParent();
((DatasetModel) getDefaultModel()).setSize
(parentBean.SystemChoicesValue.size());
Any Suggestions on this.
Thanks
Namburi
[email protected] -
NullPointerException - Cannot get the value from variable f_cashGiven
In SubCheckout.java (a POS), what I want is when Payment button (f_cashPayment) is pressed, the action "Cash" is performed, get the value from Cash Given (f_cashGiven), do the subtraction and post the value as Cash Return (f_cashReturn). The code is filled in actionPerformed. But I cannot get the value by using f_cashGiven.getValue() from VNumber class. It returns NULL. This should be quite straight forward, but I do not know what is wrong. Please help!
Enclosed please find the source code of SubCheckout.java and VNumber.java
This is the code of SubCheckout.java :
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
package org.compiere.pos;
import java.awt.*;
import java.awt.event.*;
import java.math.BigDecimal;
import javax.swing.border.*;
import org.compiere.grid.ed.*;
import org.compiere.swing.*;
import org.compiere.util.*;
* POS Checkout Sub Panel
* @author Jorg Janke
* @version $Id: SubCheckout.java,v 1.3 2005/03/11 20:28:22 jjanke Exp $
public class SubCheckout extends PosSubPanel implements ActionListener
* Constructor
* @param posPanel POS Panel
public SubCheckout (PosPanel posPanel)
super (posPanel);
} // PosSubCheckout
private CButton f_register = null;
private CButton f_summary = null;
private CButton f_process = null;
private CButton f_print = null;
private CLabel f_lcreditCardNumber = null;
private CTextField f_creditCardNumber = null;
private CLabel f_lcreditCardExp = null;
private CTextField f_creditCardExp = null;
private CLabel f_lcreditCardVV = null;
private CTextField f_creditCardVV = null;
private CButton f_cashPayment = null;
private CLabel f_lcashGiven = null;
private VNumber f_cashGiven = null;
private CLabel f_lcashReturn = null;
private VNumber f_cashReturn = null;
private CButton f_creditPayment = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubCheckout.class);
* Initialize
public void init()
// Title
TitledBorder border = new TitledBorder(Msg.getMsg(Env.getCtx(), "Checkout"));
setBorder(border);
// Content
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = INSETS2;
// -- 0
gbc.gridx = 0;
f_register = createButtonAction("Register", null);
gbc.gridy = 0;
add (f_register, gbc);
f_summary = createButtonAction("Summary", null);
gbc.gridy = 1;
add (f_summary, gbc);
f_process = createButtonAction("Process", null);
gbc.gridy = 2;
add (f_process, gbc);
f_print = createButtonAction("Print", null);
gbc.gridy = 3;
add (f_print, gbc);
// -- 1 -- Cash
gbc.gridx = 1;
gbc.gridheight = 2;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = .1;
CPanel cash = new CPanel(new GridBagLayout());
cash.setBorder(new TitledBorder(Msg.getMsg(Env.getCtx(), "Cash")));
gbc.gridy = 0;
add (cash, gbc);
GridBagConstraints gbc0 = new GridBagConstraints();
gbc0.insets = INSETS2;
gbc0.anchor = GridBagConstraints.WEST;
f_lcashGiven = new CLabel(Msg.getMsg(Env.getCtx(),"CashGiven"));
cash.add (f_lcashGiven, gbc0);
f_cashGiven = new VNumber("CashGiven", false, false, true, DisplayType.Amount,
Msg.translate(Env.getCtx(), "CashGiven"));
f_cashGiven.addActionListener(this);
f_cashGiven.setColumns(10, 25);
cash.add (f_cashGiven, gbc0);
f_cashGiven.setValue(Env.ZERO);
f_lcashReturn = new CLabel(Msg.getMsg(Env.getCtx(),"CashReturn"));
cash.add (f_lcashReturn, gbc0);
f_cashReturn = new VNumber("CashReturn", false, true, false, DisplayType.Amount,
"CashReturn");
f_cashReturn.setColumns(10, 25);
cash.add (f_cashReturn, gbc0);
f_cashReturn.setValue(Env.ZERO);
f_cashPayment = createButtonAction("Payment", null);
f_cashPayment.setActionCommand("Cash");
gbc0.anchor = GridBagConstraints.EAST;
gbc0.weightx = 0.1;
cash.add (f_cashPayment, gbc0);
// -- 1 -- Creditcard
CPanel creditcard = new CPanel(new GridBagLayout());
creditcard.setBorder(new TitledBorder(Msg.translate(Env.getCtx(), "CreditCardType")));
gbc.gridy = 2;
add (creditcard, gbc);
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.insets = INSETS2;
gbc1.anchor = GridBagConstraints.WEST;
gbc1.gridx = 0;
gbc1.gridy = 0;
f_lcreditCardNumber = new CLabel(Msg.translate(Env.getCtx(), "CreditCardNumber"));
creditcard.add (f_lcreditCardNumber, gbc1);
gbc1.gridy = 1;
f_creditCardNumber = new CTextField(18);
creditcard.add (f_creditCardNumber, gbc1);
gbc1.gridx = 1;
gbc1.gridy = 0;
f_lcreditCardExp = new CLabel(Msg.translate(Env.getCtx(),"CreditCardExp"));
creditcard.add (f_lcreditCardExp, gbc1);
gbc1.gridy = 1;
f_creditCardExp = new CTextField(5);
creditcard.add (f_creditCardExp, gbc1);
gbc1.gridx = 2;
gbc1.gridy = 0;
f_lcreditCardVV = new CLabel(Msg.translate(Env.getCtx(), "CreditCardVV"));
creditcard.add (f_lcreditCardVV, gbc1);
gbc1.gridy = 1;
f_creditCardVV = new CTextField(5);
creditcard.add (f_creditCardVV, gbc1);
gbc1.gridx = 3;
gbc1.gridy = 0;
gbc1.gridheight = 2;
f_creditPayment = createButtonAction("Payment", null);
f_creditPayment.setActionCommand("CreditCard");
gbc1.anchor = GridBagConstraints.EAST;
gbc1.weightx = 0.1;
creditcard.add (f_creditPayment, gbc1);
} // init
* Get Panel Position
public GridBagConstraints getGridBagConstraints()
GridBagConstraints gbc = super.getGridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
return gbc;
} // getGridBagConstraints
* Dispose - Free Resources
public void dispose()
super.dispose();
} // dispose
* Action Listener
* @param e event
public void actionPerformed (ActionEvent e)
String action = e.getActionCommand();
if (action == null || action.length() == 0)
return;
log.info( "PosSubCheckout - actionPerformed: " + action);
if (e.getSource() == f_cashGiven) {
f_cashGiven.setValue(f_cashGiven.getValue());
System.out.println("f_cashGiven"+f_cashGiven.getDisplay());
// Register
// Summary
// Print
if (action.equals("Cash")) {
BigDecimal CashGiven, GrandTotal, CashReturn;
System.out.println("Cash given is "+f_cashGiven.getDisplay());
CashGiven = (BigDecimal)f_cashGiven.getValue();
GrandTotal = (BigDecimal)p_posPanel.f_curLine.getOrder().getGrandTotal();
CashReturn = CashGiven.subtract(GrandTotal);
f_cashReturn.setValue(CashReturn);
// Cash (Payment)
// CreditCard (Payment)
} // actionPerformed
} // PosSubCheckoutThis is the code of VNumber.java :
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
package org.compiere.grid.ed;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.math.*;
import java.text.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.text.*;
import org.compiere.apps.*;
import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*;
* Number Control
* @author Jorg Janke
* @version $Id: VNumber.java,v 1.41 2005/09/03 01:57:16 jjanke Exp $
public final class VNumber extends JComponent
implements VEditor, ActionListener, KeyListener, FocusListener
/** Number of Columns (12) */
public final static int SIZE = 12;
* IDE Bean Constructor
public VNumber()
this("Number", false, false, true, DisplayType.Number, "Number");
} // VNumber
* Create right aligned Number field.
* no popup, if WindowNo == 0 (for IDs)
* @param columnName column name
* @param mandatory mandatory
* @param isReadOnly read only
* @param isUpdateable updateable
* @param displayType display type
* @param title title
public VNumber(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
int displayType, String title)
super();
super.setName(columnName);
m_columnName = columnName;
m_title = title;
setDisplayType(displayType);
LookAndFeel.installBorder(this, "TextField.border");
this.setLayout(new BorderLayout());
// this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length
// int height = m_text.getPreferredSize().height;
// setMinimumSize(new Dimension (30,height));
// *** Text ***
m_text.setBorder(null);
m_text.setHorizontalAlignment(JTextField.TRAILING);
m_text.addKeyListener(this);
m_text.addFocusListener(this);
// Background
setMandatory(mandatory);
this.add(m_text, BorderLayout.CENTER);
// *** Button ***
m_button.setIcon(Env.getImageIcon("Calculator10.gif"));
m_button.setMargin(new Insets(0, 0, 0, 0));
m_button.setFocusable(false);
m_button.addActionListener(this);
this.add (m_button, BorderLayout.EAST);
// Prefereed Size
this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length
// Size
setColumns(SIZE, CComboBox.FIELD_HIGHT-4);
// ReadWrite
if (isReadOnly || !isUpdateable)
setReadWrite(false);
else
setReadWrite(true);
} // VNumber
* Dispose
public void dispose()
m_text = null;
m_button = null;
m_mField = null;
} // dispose
* Set Document
* @param doc document
protected void setDocument(Document doc)
m_text.setDocument(doc);
} // getDocument
private String m_columnName;
protected int m_displayType; // Currency / UoM via Context
private DecimalFormat m_format;
private String m_title;
private boolean m_setting;
private String m_oldText;
private String m_initialText;
private boolean m_rangeSet = false;
private Double m_minValue;
private Double m_maxValue;
private boolean m_modified = false;
/** The Field */
private CTextField m_text = new CTextField(SIZE); // Standard
/** The Button */
private CButton m_button = new CButton();
private MField m_mField = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(VNumber.class);
* Set no of Columns
* @param columns columns
public void setColumns (int columns, int height)
m_text.setPreferredSize(null);
m_text.setColumns(columns);
Dimension size = m_text.getPreferredSize();
if (height > size.height) // default 16
size.height = height;
if (CComboBox.FIELD_HIGHT-4 > size.height)
size.height = VLookup.FIELD_HIGHT-4;
this.setPreferredSize(size); // causes r/o to be the same length
this.setMinimumSize(new Dimension (columns*10, size.height));
m_button.setPreferredSize(new Dimension(size.height, size.height));
} // setColumns
* Set Range with min & max
* @param minValue min value
* @param maxValue max value
* @return true, if accepted
public boolean setRange(Double minValue, Double maxValue)
m_rangeSet = true;
m_minValue = minValue;
m_maxValue = maxValue;
return m_rangeSet;
} // setRange
* Set Range with min & max = parse US style number w/o Gouping
* @param minValue min value
* @param maxValue max value
* @return true if accepted
public boolean setRange(String minValue, String maxValue)
if (minValue == null || maxValue == null)
return false;
try
m_minValue = Double.valueOf(minValue);
m_maxValue = Double.valueOf(maxValue);
catch (NumberFormatException nfe)
return false;
m_rangeSet = true;
return m_rangeSet;
} // setRange
* Set and check DisplayType
* @param displayType display type
public void setDisplayType (int displayType)
m_displayType = displayType;
if (!DisplayType.isNumeric(displayType))
m_displayType = DisplayType.Number;
m_format = DisplayType.getNumberFormat(displayType);
m_text.setDocument (new MDocNumber(displayType, m_format, m_text, m_title));
} // setDisplayType
* Set ReadWrite
* @param value value
public void setReadWrite (boolean value)
if (m_text.isReadWrite() != value)
m_text.setReadWrite(value);
if (m_button.isReadWrite() != value)
m_button.setReadWrite(value);
// Don't show button if not ReadWrite
if (m_button.isVisible() != value)
m_button.setVisible(value);
} // setReadWrite
* IsReadWrite
* @return true if rw
public boolean isReadWrite()
return m_text.isReadWrite();
} // isReadWrite
* Set Mandatory (and back bolor)
* @param mandatory mandatory
public void setMandatory (boolean mandatory)
m_text.setMandatory(mandatory);
} // setMandatory
* Is it mandatory
* @return true if mandatory
public boolean isMandatory()
return m_text.isMandatory();
} // isMandatory
* Set Background
* @param color color
public void setBackground(Color color)
m_text.setBackground(color);
} // setBackground
* Set Background
* @param error error
public void setBackground (boolean error)
m_text.setBackground(error);
} // setBackground
* Set Foreground
* @param fg foreground
public void setForeground(Color fg)
m_text.setForeground(fg);
} // setForeground
* Set Editor to value
* @param value value
public void setValue(Object value)
log.finest("Value=" + value);
if (value == null)
m_oldText = "";
else
m_oldText = m_format.format(value);
// only set when not updated here
if (m_setting)
return;
m_text.setText (m_oldText);
m_initialText = m_oldText;
m_modified = false;
} // setValue
* Property Change Listener
* @param evt event
public void propertyChange (PropertyChangeEvent evt)
if (evt.getPropertyName().equals(org.compiere.model.MField.PROPERTY))
setValue(evt.getNewValue());
} // propertyChange
* Return Editor value
* @return value value (big decimal or integer)
public Object getValue()
if (m_text == null || m_text.getText() == null || m_text.getText().length() == 0)
return null;
String value = m_text.getText();
// return 0 if text deleted
if (value == null || value.length() == 0)
if (!m_modified)
return null;
if (m_displayType == DisplayType.Integer)
return new Integer(0);
return Env.ZERO;
if (value.equals(".") || value.equals(",") || value.equals("-"))
value = "0";
try
Number number = m_format.parse(value);
value = number.toString(); // converts it to US w/o thousands
BigDecimal bd = new BigDecimal(value);
if (m_displayType == DisplayType.Integer)
return new Integer(bd.intValue());
if (bd.signum() == 0)
return bd;
return bd.setScale(m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP);
catch (Exception e)
log.log(Level.SEVERE, "Value=" + value, e);
if (m_displayType == DisplayType.Integer)
return new Integer(0);
return Env.ZERO;
} // getValue
* Return Display Value
* @return value
public String getDisplay()
return m_text.getText();
} // getDisplay
* Get Title
* @return title
public String getTitle()
return m_title;
} // getTitle
* Plus - add one.
* Also sets Value
* @return new value
public Object plus()
Object value = getValue();
if (value == null)
if (m_displayType == DisplayType.Integer)
value = new Integer(0);
else
value = Env.ZERO;
// Add
if (value instanceof BigDecimal)
value = ((BigDecimal)value).add(Env.ONE);
else
value = new Integer(((Integer)value).intValue() + 1);
setValue(value);
return value;
} // plus
* Minus - subtract one, but not below minimum.
* Also sets Value
* @param minimum minimum
* @return new value
public Object minus (int minimum)
Object value = getValue();
if (value == null)
if (m_displayType == DisplayType.Integer)
value = new Integer(minimum);
else
value = new BigDecimal(minimum);
setValue(value);
return value;
// Subtract
if (value instanceof BigDecimal)
BigDecimal bd = ((BigDecimal)value).subtract(Env.ONE);
BigDecimal min = new BigDecimal(minimum);
if (bd.compareTo(min) < 0)
value = min;
else
value = bd;
else
int i = ((Integer)value).intValue();
i--;
if (i < minimum)
i = minimum;
value = new Integer(i);
setValue(value);
return value;
} // minus
* Action Listener
* @param e event
public void actionPerformed (ActionEvent e)
log.config(e.getActionCommand());
if (ValuePreference.NAME.equals(e.getActionCommand()))
if (MRole.getDefault().isShowPreference())
ValuePreference.start (m_mField, getValue());
return;
if (e.getSource() == m_button)
m_button.setEnabled(false);
String str = startCalculator(this, m_text.getText(), m_format, m_displayType, m_title);
m_text.setText(str);
m_button.setEnabled(true);
try
fireVetoableChange (m_columnName, m_oldText, getValue());
catch (PropertyVetoException pve) {}
m_text.requestFocus();
} // actionPerformed
* Key Listener Interface
* @param e event
public void keyTyped(KeyEvent e) {}
public void keyPressed(KeyEvent e) {}
* Key Listener.
* - Escape - Restore old Text
* - firstChange - signal change
* @param e event
public void keyReleased(KeyEvent e)
log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar()
+ " -> " + m_text.getText());
// ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
m_text.setText(m_initialText);
m_modified = true;
m_setting = true;
try
if (e.getKeyCode() == KeyEvent.VK_ENTER) // 10
fireVetoableChange (m_columnName, m_oldText, getValue());
fireActionPerformed();
else // indicate change
fireVetoableChange (m_columnName, m_oldText, null);
catch (PropertyVetoException pve) {}
m_setting = false;
} // keyReleased
* Focus Gained
* @param e event
public void focusGained (FocusEvent e)
if (m_text != null)
m_text.selectAll();
} // focusGained
* Data Binding to MTable (via GridController.vetoableChange).
* @param e event
public void focusLost (FocusEvent e)
// log.finest(e.toString());
// APanel - Escape
if (e.getOppositeComponent() instanceof AGlassPane)
m_text.setText(m_initialText);
return;
try
fireVetoableChange (m_columnName, m_initialText, getValue());
fireActionPerformed();
catch (PropertyVetoException pve) {}
} // focusLost
* Invalid Entry - Start Calculator
* @param jc parent
* @param value value
* @param format format
* @param displayType display type
* @param title title
* @return value
public static String startCalculator(Container jc, String value,
DecimalFormat format, int displayType, String title)
log.config("Value=" + value);
BigDecimal startValue = new BigDecimal(0.0);
try
if (value != null && value.length() > 0)
Number number = format.parse(value);
startValue = new BigDecimal (number.toString());
catch (ParseException pe)
log.info("InvalidEntry - " + pe.getMessage());
// Find frame
Frame frame = Env.getFrame(jc);
// Actual Call
Calculator calc = new Calculator(frame, title,
displayType, format, startValue);
AEnv.showCenterWindow(frame, calc);
BigDecimal result = calc.getNumber();
log.config( "Result=" + result);
calc = null;
if (result != null)
return format.format(result);
else
return value; // original value
} // startCalculator
* Set Field/WindowNo for ValuePreference
* @param mField field
public void setField (MField mField)
m_mField = mField;
if (m_mField != null
&& MRole.getDefault().isShowPreference())
ValuePreference.addMenu (this, popupMenu);
} // setField
* Remove Action Listner
* @param l Action Listener
public void removeActionListener(ActionListener l)
listenerList.remove(ActionListener.class, l);
} // removeActionListener
* Add Action Listner
* @param l Action Listener
public void addActionListener(ActionListener l)
listenerList.add(ActionListener.class, l);
} // addActionListener
* Fire Action Event to listeners
protected void fireActionPerformed()
int modifiers = 0;
AWTEvent currentEvent = EventQueue.getCurrentEvent();
if (currentEvent instanceof InputEvent)
modifiers = ((InputEvent)currentEvent).getModifiers();
else if (currentEvent instanceof ActionEvent)
modifiers = ((ActionEvent)currentEvent).getModifiers();
ActionEvent ae = new ActionEvent (this, ActionEvent.ACTION_PERFORMED,
"VNumber", EventQueue.getMostRecentEventTime(), modifiers);
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2)
if (listeners==ActionListener.class)
((ActionListener)listeners[i+1]).actionPerformed(ae);
} // fireActionPerformed
} // VNumberIf getValue() returns null, you need to trace the execution of the code and figure out which sequence of code is leading to the return of null. This method looks complex - a lot of if statements. If you do not have a debugger, put System.out.println statements inside the method to figure out what's going on.
-
Swing: when trying to get the values from a JTable inside an event handler
Hi,
I am trying to write a graphical interface to compute the Gauss Elimination procedure for solving linear systems. The class for computing the output of a linear system already works fine on console mode, but I am fighting a little bit to make it work with Swing.
I put two buttons (plus labels) and a JTextField . The buttons have the following role:
One of them gets the value from the JTextField and it will be used to the system dimension. The other should compute the solution. I also added a JTable so that the user can type the values in the screen.
So whenever the user hits the button Dimensiona the program should retrieve the values from the table cells and pass them to a 2D Array. However, the program throws a NullPointerException when I try to
do it. I have put the code for copying this Matrix inside a method and I call it from the inner class event handler.
I would thank you very much for the help.
Daniel V. Gomes
here goes the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import AdvanceMath.*;
public class MathF2 extends JFrame {
private JTextField ArrayOfFields[];
private JTextField DimOfSis;
private JButton Calcular;
private JButton Ativar;
private JLabel label1;
private JLabel label2;
private Container container;
private int value;
private JTable DataTable;
private double[][] A;
private double[] B;
private boolean dimensionado = false;
private boolean podecalc = false;
public MathF2 (){
super("Math Calcs");
Container container = getContentPane();
container.setLayout( new FlowLayout(FlowLayout.CENTER) );
Calcular = new JButton("Resolver");
Calcular.setEnabled(false);
Ativar = new JButton("Dimensionar");
label1 = new JLabel("Clique no bot�o para resolver o sistema.");
label2 = new JLabel("Qual a ordem do sistema?");
DimOfSis = new JTextField(4);
DimOfSis.setText("0");
JTable DataTable = new JTable(10,10);
container.add(label2);
container.add(DimOfSis);
container.add(Ativar);
container.add(label1);
container.add(Calcular);
container.add(DataTable);
for ( int i = 0; i < 10 ; i ++ ){
for ( int j = 0 ; j < 10 ; j++) {
DataTable.setValueAt("0",i,j);
myHandler handler = new myHandler();
Calcular.addActionListener(handler);
Ativar.addActionListener(handler);
setSize( 500 , 500 );
setVisible( true );
public static void main ( String args[] ){
MathF2 application = new MathF2();
application.addWindowListener(
new WindowAdapter(){
public void windowClosing (WindowEvent event)
System.exit( 0 );
private class myHandler implements ActionListener {
public void actionPerformed ( ActionEvent event ){
if ( event.getSource()== Calcular ) {
if ( event.getSource()== Ativar ) {
//dimensiona a Matriz A
if (dimensionado == false) {
if (DimOfSis.getText()=="0") {
value = 2;
} else {
value = Integer.parseInt(DimOfSis.getText());
dimensionado = true;
Ativar.setEnabled(false);
System.out.println(value);
} else {
Ativar.setEnabled(false);
Calcular.setEnabled(true);
podecalc = true;
try {
InitValores( DataTable, value );
} catch (Exception e) {
System.out.println("Erro ao criar matriz" + e );
private class myHandler2 implements ItemListener {
public void itemStateChanged( ItemEvent event ){
private void InitValores( JTable table, int n ) {
A = new double[n][n];
B = new double[n];
javax.swing.table.TableModel model = table.getModel();
for ( int i = 0 ; i < n ; i++ ){
for (int j = 0 ; j < n ; j++ ){
Object temp1 = model.getValueAt(i,j);
String temp2 = String.valueOf(temp1);
A[i][j] = Double.parseDouble(temp2);What I did is set up a :
// This code will setup a listener for the table to handle a selection
players.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = players.getSelectionModel();
rowSM.addListSelectionListener(new Delete_Player_row_Selection(this));
//Class will take the event and call a method inside the Delete_Player object.
class Delete_Player_row_Selection
implements javax.swing.event.ListSelectionListener
Delete_Player adaptee;
Delete_Player_row_Selection (Delete_Player temp)
adaptee = temp;
public void valueChanged (ListSelectionEvent listSelectionEvent)
adaptee.row_Selection(listSelectionEvent);
in the row_Selection function
if(ex.getValueIsAdjusting()) //To remove double selection
return;
ListSelectionModel lsm = (ListSelectionModel) ex.getSource();
if(lsm.isSelectionEmpty())
System.out.println("EMtpy");
else
int selected_row = lsm.getMinSelectionIndex();
ResultSetTableModel model = (ResultSetTableModel) players.getModel();
String name = (String) model.getValueAt(selected_row, 1);
Integer id = (Integer) model.getValueAt(selected_row, 3);
This is how I got info out of a table when the user selected it
Maybe you are looking for
-
Function module-open_job
Hi , i am using function module open_close ,close_job to run the program in the background in user-exit, when i execute the transaction everthing goes fine, but when i debug it it give me a dump , stating invalid startdate. Thanks & Regards
-
Adobe Flash Media Live Encoder 3 - Video Hardware Acceleration Warning
I have been looking for an answer for this error for a few days without any luck. I just loaded the Adobe Free Encoder 3 and the Flash Media Server (Free Version) on a Dell PowerEdge 1950 running Windows 2003 server standard edition with Service Pack
-
Calendar input help in web layout
Hi Community, I have a BPS web interface with a planning layout for input of date, which has been generated by the means of bps_wb. This layout uses key figure of type date in data columns. If I execute the layout in BPS0 the calendar input help pop-
-
Feature requests: Quotas & status reports
I just sent the following feedback to Apple: "Beside the highly missed backup to AirDisks I would appreciate two additional features in TimeMachine: (1.) I'd like to set a quota for the backup set as I don't want it to fill up the device completely (
-
Macbook facetime small window showing myself is dissapear
I don't know why but sometimes when using facetime, the small window showing myself is not there, but my friend can see and hear me, everything is normal,except the small window is missing. Is anyone know how to fix this?