Combo box validation
Hi all
I am new to jsp and servlet I have a requirement , in a combo box I don't want to select the default value like
select I want a client side validation for this.
I don't fully understand you. Are you talking about JSF? The h:selectOneMenu and h:selectManyMenu both just defaults to an empty item. Clientside validation can only be done with Javascript.
Similar Messages
-
Hi All,
I'm developing a Form which has BP Code and a ComboBox which, after entering a valid Supplier in the BPCode EditText, updates the ComboBox with the Supplier Catalog Numbers of all the Items where the CardCode (in OITM) matches the BPCode. I have this working for the first change of BPCode but when the BPCode changes I want to update the ComboBox ValidValues. I have tried many methods but cannot remove the ValidValues which are already there. I have tried linking the ComboBox to a DataTable, clearing the DataTable and rebinding but this doesn't seem to work either.
Any help on removing ValidValues from a list when I don't know what is already there (as the VV list is now out of scope) or adding a data bound ComboBox would be most appreciated.
Thanks in anticipation,
DavidHi David,
Try following
'get the reference to the state combo box
oCombo = oForm.Items.Item("combo box unique id").Specific
'remove existing items if any
'before adding new items
For Flag = 0 To oCombo.ValidValues.Count - 1
oCombo.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
Next
After this, use a recordset or datatable to retrieve the records, and than a loop to add valid values to the combo box.
Rahul -
Need help on combo box validation in jsf
Hi All,
I have a combo box with some options. User has to select one option and has to submit the form. If he doesnt select any option and submit the form i need to display an error message saying that PLEASE SELECT AN OPTION AND SUBMIT.
I am using RATIONAL APPLICATION DEVELOPER 6.0 as my IDE.
please help me its an urgent requirementOn submit check if he has an option selected.
If not do the following:
FacesContext.getCurrentInstance().addMessage(componentId,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
errorMessage,
errorMessage));
return null;
The componentId is the id of the selectOneMenu -
How I can stop the combo box with list of values from fireing validations
Hi I'm using Jdeveloper 11.1.2.3.0
Using Hr Schema employees table
I Display employees data in af:table
and I make List Of values on Department_id filed to easy change the employee department
and another one on Job_id filed
and Imake them UI Hints as ( combo box with list of values ) in the employeesVO
the problem is when I Select a value from department or jobs ( combo box with list of values )
fires the entire filed validations for mandatory atributes
Note : the af:table Property ( contedelivery) is set to (immediate )
How I can stop the combo box with list of values from fireing validationscheck it out.,
http://andrejusb.blogspot.in/2012/09/what-to-do-when-adf-editable-table.html -
I am creating a pdf form that will be used as a calculator, and my javascript knowledge is pretty rudimentary. I can do the simple things, some of what I need to do is over my head.
1. I believe I need to use a combo box to pre populate certain fields. I have 13 variables in the dropdown to choose from, and whatever the client chooses will pre populate three other fields (and each of the 13 variables will populate those three fields differently). I'm not exactly sure how to go about doing this. Is it custom keystroke script or does it require a document script? Also, I'm guessing that whatever script will be a series of if/then statements, correct?
2. Once all the fields have been populated (be it pre population or filled in by the customer), I need to calculate the answer which is not my main problem—I already have the proper calculations in place and they work. The problem is that the answer has a maximum value even if the actual value goes over that max number. So, the actual answer is 14 but the max value can only be 12. How do I get the calculation to replace that actual number (14) with the max number (12)? Is that in the validation tab or should that go elsewhere?
I feel like I know just enough to be dangerous but not terribly effective. Any help is appreciated.
Thanks!1. There is a tutorial on this here:
http://acrobatusers.com/tutorials/change_another_field
2. To set the maximum value to 12, try this as the custom calculation script for the field:
//Custom calculation script
//Get value of text field
var a = this.getField("Text1").value;
//If it is > 12, then make it 12
if (a > 12){
a=12
event.value = a
You need to replace "Text1" with the name of the field in your form. -
Show text box from one combo box selection
Total newb here and need help. I tried searching for a javascript to copy/paste, but without any luck. I am using Acrobat Pro 9.2.0. If you could help me out with the javascript or with directions on how to make the following be accomplished, I would be greatly appreciative.
I am creating a fillable PDF and currently have a combo box that is labeled "Internship Satisfied By" with the options of "TCoB PDP", "MRKTNG 4185", and "Other College". I would like a hidden text box (where the end user can fill in to explain) to become visible only when the end user selects the "Other College" option, but stay hidden for the other selections. The hidden text box is labeled "Internship Explained".
Thanks in advance! JarrodUse this code as the combo box's validation script:
if (event.value == "Other College") {
getField("Internship Explained").display = display.visible;
} else {
getField("Internship Explained").display = display.hidden; -
Adding an event listener to combo box
I am working on a mortgage calculator and I cannot figure out how to add an event listener to a combo box.
I want to get the mortgage term and interest rate to calucate the mortgage using the combo cox. Here is my program.
Modify the mortgage program to allow the user to input the amount of a mortgage
and then select from a menu of mortgage loans: 7 year at 5.35%, 15 year at 5.50%, and
30 year at 5.75%. Use an array for the different loans. Display the mortgage payment
amount. Then, list the loan balance and interest paid for each payment over the term
of the loan. Allow the user to loop back and enter a new amount and make a new
selection, with resulting new values. Allow user to exit if running as an application
(can't do that for an applet though).
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.text.NumberFormat;
import java.util.Locale;
//creates class MortgageCalculator
public class MortgageCalculator extends JFrame implements ActionListener {
//creates title for calculator
JPanel row = new JPanel();
JLabel mortgageCalculator = new JLabel("MORTGAGE CALCULATOR", JLabel.CENTER);
//creates labels and text fields for amount entered
JPanel firstRow = new JPanel(new GridLayout(3,1,1,1));
JLabel mortgageLabel = new JLabel("Mortgage Payment $", JLabel.LEFT);
JTextField mortgageAmount = new JTextField(10);
JPanel secondRow = new JPanel();
JLabel termLabel = new JLabel("Mortgage Term/Interest Rate", JLabel.LEFT);
String[] term = {"7", "15", "30"};
JComboBox mortgageTerm = new JComboBox(term);
JPanel thirdRow = new JPanel();
JLabel interestLabel = new JLabel("Interest Rate (%)", JLabel.LEFT);
String[] interest = {"5.35", "5.50", "5.75"};
JComboBox interestRate = new JComboBox(interest);
JPanel fourthRow = new JPanel(new GridLayout(3, 2, 10, 10));
JLabel paymentLabel = new JLabel("Monthly Payment $", JLabel.LEFT);
JTextField monthlyPayment = new JTextField(10);
//create buttons to calculate payment and clear fields
JPanel fifthRow = new JPanel(new GridLayout(3, 2, 1, 1));
JButton calculateButton = new JButton("CALCULATE PAYMENT");
JButton clearButton = new JButton("CLEAR");
JButton exitButton = new JButton("EXIT");
//Display area
JPanel sixthRow = new JPanel(new GridLayout(2, 2, 10, 10));
JLabel displayArea = new JLabel(" ", JLabel.LEFT);
JTextArea textarea = new JTextArea(" ", 8, 50);
public MortgageCalculator() {
super("Mortgage Calculator"); //title of frame
setSize(550, 350); //size of frame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
GridLayout grid = new GridLayout(7, 3, 10, 10);
pane.setLayout(grid);
pane.add(row);
pane.add(mortgageCalculator);
pane.add(firstRow);
pane.add(mortgageLabel);
pane.add(mortgageAmount);
pane.add(secondRow);
pane.add(termLabel);
pane.add(mortgageTerm);
pane.add(thirdRow);
pane.add(interestLabel);
pane.add(interestRate);
pane.add(fourthRow);
pane.add(paymentLabel);
pane.add(monthlyPayment);
monthlyPayment.setEnabled(false);
pane.add(fifthRow);
pane.add(calculateButton);
pane.add(clearButton);
pane.add(exitButton);
pane.add(sixthRow);
pane.add(textarea); //adds texaarea to frame
pane.add(displayArea);
setContentPane(pane);
setVisible(true);
//Adds Listener to buttons
calculateButton.addActionListener(this);
clearButton.addActionListener(this);
exitButton.addActionListener(this);
mortgageTerm.addActionListener(this);
interestRate.addActionListener(this);
public void actionPerformed(ActionEvent event) {
Object command = event.getSource();
JComboBox mortgageTerm = (JComboBox)event.getSource();
String termYear = (String)mortgageTerm.getSelectedItem();
if (command == calculateButton) //calculates mortgage payment
int year = Integer.parseInt(mortgageTerm.getText());
double rate = new Double(interestRate.getText()).doubleValue();
double mortgage = new Double(mortgageAmount.getText()).doubleValue();
double interest = rate /100.0 / 12.0;
double monthly = mortgage *(interest/(1-Math.pow(interest+1,-12.0 * year)));
NumberFormat myCurrencyFormatter;
myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US);
monthlyPayment.setText(myCurrencyFormatter.format(monthly));
if(command == clearButton) //clears all text fields
mortgageAmount.setText(null);
//mortgageTerm.setText(null);
//interestRate.setText(null);
monthlyPayment.setText(null);
if(command == exitButton) //sets exit button
System.exit(0);
public static void main(String[] arguments) {
MortgageCalculator mor = new MortgageCalculator();The OP already did this to both JComboBoxes.
mochatay, here is a new actionPerformed method for you to use.
I've improved a few things here and there...
1) You can't just cast the ActionEvent's source into a JComboBox!
What if it was a JButton that fired the event? Then you would get ClassCastExceptions (I'm sure you did)
So check for all options, what the source of the ActionEvent actually was...
2) You can't assume the user will always type in valid data.
So enclose the Integer and Double parse methods in try-catch brakcets.
Then you can do something when you know that the user has entered invalid input
(like tell him/her what a clumsy idiot they are !)
3) As soon as user presses an item in any JComboBox, just re-calculate.
I did this here by programmatically clicking the 'Calculate' button.
Alternatively, you could have a 'calculate' method, which does everything inside the
if(command==calculateButton) if-block.
This will be called when:
a)calculateButton is pressed
b)when either of the JComboBoxes are pressed.
public void actionPerformed (ActionEvent event)
Object command = event.getSource ();
if (command == calculateButton) //calculates mortgage payment
int year = 0;
double rate = 0;
double mortgage = 0;
double interest = 0;
/* If user has input invalid data, tell him so
and return (Exit from this method back to where we were before */
try
year = Integer.parseInt (mortgageTerm.getSelectedItem ().toString ());
rate = new Double (interestRate.getSelectedItem ().toString ()).doubleValue ();
mortgage = new Double (mortgageAmount.getText ()).doubleValue ();
interest = rate / 100.0 / 12.0;
catch (NumberFormatException nfe)
/* Display a message Dialogue box with a message */
JOptionPane.showMessageDialog (this, "Error! Invalid input!");
return;
double monthly = mortgage * (interest / (1 - Math.pow (interest + 1, -12.0 * year)));
NumberFormat myCurrencyFormatter;
myCurrencyFormatter = NumberFormat.getCurrencyInstance (Locale.US);
monthlyPayment.setText (myCurrencyFormatter.format (monthly));
else if (command == clearButton) //clears all text fields
/* Better than setting it to null (I think) */
mortgageAmount.setText ("");
//mortgageTerm.setText(null);
//interestRate.setText(null);
monthlyPayment.setText ("");
else if (command == exitButton) //sets exit button
System.exit (0);
else if (command == mortgageTerm)
/* Programmatically 'clicks' the button,
As is user had clicked it */
calculateButton.doClick ();
else if (command == interestRate)
calculateButton.doClick ();
//JComboBox mortgageTerm = (JComboBox) event.getSource ();
//String termYear = (String) mortgageTerm.getSelectedItem ();
}Hope this solves your problems.
I also hope you'll be able to learn from what I've indicated, so you can use similar things yourself
in future!
Regards,
lutha -
How to use the Combo Box In MAtrix Colums
HI Experts,
Good Mornong.How to use the Combo Box In MAtrix Colums?
Regards And Thanks,
M.Thippa Reddyhi,
loading data in to the combobox on form load.but, it should be done when atleast one row is active.
the values what ever you are inserting in to combo should be less than or eqhal to 100 or 150.if it exceeds beyond that performance issue arises.it takes more time to load all the data.so, it is better to have 100 or less.
oMatrix.AddRow()
RS = Nothing
RS = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
RS.DoQuery("select ItemCode,ItemName from oitm")
oCombo = oMatrix.Columns.Item("ColumnUID").Cells.Item(oMatrix.RowCount).Specific
For i = 1 To RS.RecordCount
If RS.EoF = False Then
oCombo.ValidValues.Add(RS.Fields.Item("ItemCode").Value,RS.Fields.Item("ItemName").Value)
RS.MoveNext()
End If
Next
the above code is inserting data from database to column combobox.
you can fill combo directly also as shown below.
oCombo.ValidValues.Add("x","1")
oCombo.ValidValues.Add("y","2")
oCombo.ValidValues.Add("z","3")
oCombo.ValidValues.Add("","")
and what ever the values you are filling into combo should be unique.other wise it shows valid value exists.
regards,
varma -
InfoView - How to Restrict values of Month Dimension Combo Box
Post Author: alexrox
CA Forum: Publishing
Product: Business Objects Enterprise XI R2
Version: XI R2
Patches Applied:
Operating System(s): Linux RHEL 4 x86
Database(s): Oracle 10gR2
Error Messages:Steps to Reproduce:
Hello, we are using Business Objects Enterprise XI R2 in the company I work, and we are facing a problem in some web intelligence reports.Our BO version is in Spanish, so maybe I do not translate some BO terms properly into English.
We have the "Time" class in the Universe we use, and in that class, we have the "month" dimension.
When we create some reports in InfoView, we can use the "month" dimension to display the results of that month (dragging and dropping that dimension in the "Analysis Context" Area).
The user can choose values in the "month" dimention through a combobox in the "analysis context" area. The problem is that Infoview allows the user to select the value "all the values" of that dimension, I mean, all the months, so that the results of the report are according to the "automatic aggregation" calculated of the values of that dimension (all the months).
But, we do not want to allow the user to select that value (all the values) of that dimension, because it causes that the report displays incorrect results (we have some percentages that have incorrect values in the aggregation, for example). I hope that you understand the problem I have tried to explain.
My question is how can we restrict so that the combo box (of the month dimension at the analysis context area ) does not allow to select "all the values"?
Is it possible? If so, do we have to make a change in the universe or is it a restriction of the web intelligence repport?
Thank you very much!
Alejandro Usero RuizPost Author: jsanzone
CA Forum: Publishing
Alejandro,
In your posting, quote "(we have some percentages that have incorrect values in the aggregation, for example).", I'm wondering if you are calculating the percentages within your universe or not? I.e. do you have a universe object that in essence is doing the math? If so, I might suggest that you not do it this way (even though in total aggregation calculations this will produce a valid result), but in disaggregate calculations (during the users "slicing and dicing") the percentages are not re-calculated by the BusObjects tool because it thinks that the data it received from the SQL output is good to go, and this is where the incorrect values in the aggregation start to show up. We had this problem too, so we ceased from calculating at the universe level and built a local variable to the report, thus BusObjects will recalcuate the percentage properly for each level of aggregation that user selects. The downside to this approach is that every report that has percentage calculations will require the local variable to be built for that report. Even users who build their own reports will have to build their own local variable to compute the percentage for their reports. The upside is that the calculations will be correct every time. -
How to populate values from database into a Combo Box?
Hi,
How to display all the values of a field of a database table in a combo box inside a grid in B1 user defined form?
Regards,
Sudeshna.Hi,
If you are trying to do this on a system form (I gues this is your case, reading the other question), for example Sales Orders, and you want to show the values from a User Defined Table (UDT), you just need to add a User Defined Field on Marketing Documents Line level, and say it is linked to the UDT.
SBO will automatically show the combo with the values on the Code field of the UDT.
Regards,
Ibai Peña
Sorry, I didn´t read the post well.
What you could do is each time the form is loaded, read the values from the table, and asign them as Valid Values for the combobox column. You can do this programatically, or using XML (which is recommended becouse of better performance).
Message was edited by: Ibai Peña -
How to retrieve data in Combo box?
:mad; I need to do a form for delivery order. Just fill some
personal data and order of product. Inside I have some combo box of
product, but I need save the record into txt file (just once time)
then need to retrieve the data from txt file onto combo box. I have
attached the code, I don't know which part got wrong, anybody who
get help me?"roy16" <[email protected]> wrote in message
news:[email protected]...
>
I need to do a form for delivery order. Just fill
some personal data
> and
> order of product. Inside I have some combo box of
product, but I need
> save the
> record into txt file (just once time) then need to
retrieve the data from
> txt
> file onto combo box. I have attached the code, I don't
know which part got
> wrong, anybody who get help me?
>
> Combo box code :
> controls := wcGetControlList()
> listing := "Choose an Item"^Return^"Hot
> Chocholate"^Return^"Tea"^Return^"Coffee"^Return^"Low fat
> Milk"^Return^"Full
> Cream Milk"^Return^"Orange Juice"^Return^"Purified
Water"
> id_list := wcDisplayControl(350, 350, 150, 21,
"ComboBox", "wcS")
> propList := wcGetPropertyList(id_list)
>
>
> Save the data from Combo box list :
> data := wcGetPropertyValue(id_list, "value")^Return
data at this point will be some number between 0 and 7 and
your appended
return.
> WriteExtFile("list2.txt", data)
>
> Read the data from txt :
> data := ReadExtFile("list2.txt")
This will again be a string that contains a number and a
return.
> Convert string to list :
> id_list := [:]
Before, you are populating id_list with a single number that
is the _ID_ of
the winCtrl . Now, you are changing it to an empty property
list. Why?
> AddProperty(data^id_list,controls ,GetLine(data,1))
The first parameter of AddProperty is supposed to be the name
of a variable
which is a property list. As such, you couldn't use a
concatenated
expression there. Even if you could, an Authorware variable
cannot begin
with a number, which data always will in this instance. It
also cannot
contain a return. _And_ the characters "[:]" are not valid
parts of a
variable name either. Next, you're trying to add a property
that looks
something like:
"Button\rCheckBox\rCheckListBox\rColorCombo\rComboBox\rDriveCombo\rEdit..."
While a property list _can_ have strings instead of symbols
as the keys to
the values, this is not documented or officially supported.
Even if it
were, you _cannot_ have a key with returns in it, and I have
no idea why
you'd want to!
Here are the steps you should be using:
1) Create your WinCtrl and store its ID in a regular numeric
value (I'll
call it wcID for convenience)
2) Set its Items property to listing.
3) Check for the existence (FileType) of your file with the
value of the
winCtrl in it. If it exists, set the value property of wcID
to the contents
of the file.
4) You're using wcS as your change event, so set up a
conditional on false
to true with wcS as the condition.
5) Inside that response, write the "value" property (without
the return) of
the wcID control to file.
HTH;
Amy -
How to fetch records from the database into a combo box?
Hi:
I´m really new with ABLBPM and I´m trying to fetch records from the database to display them into a combo box as valid values for a presentation but I´m using a dynamic method with this code:
<em>for each row in SELECT campo1, campo2 from TABLE</em>
<em>do</em>
<em>solicitudes[] = [row.campo1, row.campo2]</em>
<em>end</em>
<em>return solicitudes
</em>And the debugger says that SQL instructions can be used only in fuctions and procedures that are executed on the server.
Do you know another way to do it?
P.D. Sorry for my terrible english
GreetingsHi Steve,
Thank you, your idea is perfect, but when I try to run the screenflow where the combo should be filled I get this error:
fuego.lang.ComponentExecutionException: No se ha podido ejecutar correctamente la tarea.
Motivo: 'java.lang.NullPointerException'.
at fuego.web.execution.InteractiveExecution.setExecutionError(InteractiveExecution.java:307)
at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:166)
at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
at fuego.webdebugger.servlet.DebuggerServlet.redirect(DebuggerServlet.java:136)
at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:85)
at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at fuego.web.execution.servlet.ServletExternalContext.forwardInternal(ServletExternalContext.java:197)
at fuego.web.execution.servlet.ServletExternalContext.processAction(ServletExternalContext.java:110)
at fuego.webdebugger.servlet.DebuggerExecution.dispatchComponentExecution(DebuggerExecution.java:64)
at fuego.web.execution.InteractiveExecution.invokePrepare(InteractiveExecution.java:351)
at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:192)
at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:223)
at fuego.webdebugger.servlet.DebuggerServlet.doDebug(DebuggerServlet.java:148)
at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:82)
at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
Any ideas??
Thanks and greetings -
Editable Combo box in a JTable
Hi,
Is it possible to have an editable combo Box in a JTable with an item Listener attached to the combo Box?
Based on whatever value the user enters in that column that is rendered as a combo Box(editable) i should be able to do some validation. Is this possible?
Thanks in advance for your time and patience.
ArchanaHere's a start:
public class FileModel5 extends AbstractTableModel
public boolean isEditable = false;
protected static int NUM_COLUMNS = 3;
// initialize number of rows to start out with ...
protected static int START_NUM_ROWS = 0;
protected int nextEmptyRow = 0;
protected int numRows = 0;
static final public String file = "File";
static final public String mailName = "Mail Id";
static final public String postName = "Post Office Id";
static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
// List of data
protected Vector data = null;
public FileModel5()
data = new Vector();
public boolean isCellEditable(int rowIndex, int columnIndex)
// The 2nd & 3rd column or Value field is editable
if(isEditable)
if(columnIndex > 0)
return true;
return false;
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c)
return getValueAt(0, c).getClass();
* Retrieves number of columns
public synchronized int getColumnCount()
return NUM_COLUMNS;
* Get a column name
public String getColumnName(int col)
return columnNames[col];
* Retrieves number of records
public synchronized int getRowCount()
if (numRows < START_NUM_ROWS)
return START_NUM_ROWS;
else
return numRows;
* Returns cell information of a record at location row,column
public synchronized Object getValueAt(int row, int column)
try
FileRecord5 p = (FileRecord5)data.elementAt(row);
switch (column)
case 0:
return (String)p.file;
case 1:
return (String)p.mailName;
case 2:
return (String)p.postName;
catch (Exception e)
return "";
public void setValueAt(Object aValue, int row, int column)
FileRecord5 arow = (FileRecord5)data.elementAt(row);
arow.setElementAt((String)aValue, column);
fireTableCellUpdated(row, column);
* Returns information of an entire record at location row
public synchronized FileRecord5 getRecordAt(int row) throws Exception
try
return (FileRecord5)data.elementAt(row);
catch (Exception e)
throw new Exception("Record not found");
* Used to add or update a record
* @param tableRecord
public synchronized void updateRecord(FileRecord5 tableRecord)
String file = tableRecord.file;
FileRecord5 p = null;
int index = -1;
boolean found = false;
boolean addedRow = false;
int i = 0;
while (!found && (i < nextEmptyRow))
p = (FileRecord5)data.elementAt(i);
if (p.file.equals(file))
found = true;
index = i;
} else
i++;
if (found)
{ //update
data.setElementAt(tableRecord, index);
else
if (numRows <= nextEmptyRow)
//add a row
numRows++;
addedRow = true;
index = nextEmptyRow;
data.addElement(tableRecord);
//Notify listeners that the data changed.
if (addedRow)
nextEmptyRow++;
fireTableRowsInserted(index, index);
else
fireTableRowsUpdated(index, index);
* Used to delete a record
public synchronized void deleteRecord(String file)
FileRecord5 p = null;
int index = -1;
boolean found = false;
int i = 0;
while (!found && (i < nextEmptyRow))
p = (FileRecord5)data.elementAt(i);
if (p.file.equals(file))
found = true;
index = i;
} else
i++;
if (found)
data.removeElementAt(i);
nextEmptyRow--;
numRows--;
fireTableRowsDeleted(START_NUM_ROWS, numRows);
* Clears all records
public synchronized void clear()
int oldNumRows = numRows;
numRows = START_NUM_ROWS;
data.removeAllElements();
nextEmptyRow = 0;
if (oldNumRows > START_NUM_ROWS)
fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
fireTableRowsUpdated(0, START_NUM_ROWS - 1);
* Loads the values into the combo box within the table for mail id
public void setUpMailColumn(JTable mapTable, ArrayList mailList)
TableColumn col = mapTable.getColumnModel().getColumn(1);
javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
int s = mailList.size();
for(int i=0; i<s; i++)
comboMail.addItem(mailList.get(i));
col.setCellEditor(new DefaultCellEditor(comboMail));
//Set up tool tips.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for mail Id list");
col.setCellRenderer(renderer);
//Set up tool tip for the mailName column header.
TableCellRenderer headerRenderer = col.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer)
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the Mail Id to see a list of choices");
* Loads the values into the combo box within the table for post office id
public void setUpPostColumn(JTable mapTable, ArrayList postList)
TableColumn col = mapTable.getColumnModel().getColumn(2);
javax.swing.JComboBox combo = new javax.swing.JComboBox();
int s = postList.size();
for(int i=0; i<s; i++)
combo.addItem(postList.get(i));
col.setCellEditor(new DefaultCellEditor(combo));
//Set up tool tips.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for post office Id list");
col.setCellRenderer(renderer);
//Set up tool tip for the mailName column header.
TableCellRenderer headerRenderer = col.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer)
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the Post Office Id to see a list of choices");
} -
Combo box in matrix column does not bind
Dear Sirs,
I have a master data UDO with three child tables, and I generated an xml form file using the B1DE form ganerator for this UDO.
After that I used screen painter to set some columns of the matrix bindend to the child tables as combo box.
In the load data event of the form I populate each combo box cell with the valid values I want.
Now, when I add (or update) data , the combo box let me choose the valid values correctly (and I can see the choosen value in the cell) , but then data are not saved in the DB, while the data entered in edit text columns are correclty saved.
Anyone have an idea of the problem?
Thank you for the help
MassimoMassimo,
Have a look at the SDK Sample for Matrix and DataSource ...
...\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\06.MatrixAndDataSources
This may help.
Eddy -
Combo box displays value instead of label
I have several combo boxes on a vi that will occasionally start displaying the value of an certain items instead of the string label when an element is selected. The only way to fix it is to deleted the combo box and replace it with another. This has happened several times on the same vi. Sometimes it is ok when the vi is run in the IDE but shows up in an executable. Is this a bug?
Thanks,
Bill FI think this is to be expected. Your control will have a value with no associated text.
It would be much more dangerous if LabVIEW would randomly change (e.g. coerce) the value when the strings array gets shorter by some mechanism.
You have several possibilities, for example:
(1) Check the value and coerce to the highest valid entry or switch to entry zero.
(2) Keep the array of strings at constant size, but replace the unwanted entries with empty strings (see attached), the string "out of range", "invalid selection", or similar.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ComboMOD.vi 24 KB
Maybe you are looking for
-
I have not yet bought the phone but I am wondering if I can put other SIM cards from abroad into it and how can I get a message engraved in it
-
Z68A-GD65(B3) Memory Problems
In an effort to install more memory, I'm having the following problems with my Ram: 1. The computer will only boot with a memory stick installed in the DIMM4 socket. No other socket will work. 2. Both bios and Windows only recognize the memory insta
-
Upgrade BPC 7.0 MS to 7.5 MS or 10.0 MS
Good day, We're currently using BPC 7.0 MS and are looking at long range plans. In that regard, we're trying to determine if it makes sense to upgrade to 7.5 MS or go straight to 10.0 MS. (Can we go straight to 10.0 or must we do 7.5 first?) Also h
-
I can sort my Events manually. Now I would like to sort my photos manually within the Events. Under View - Sort Photos ... Manually is dimmed as is "Reset Manual Sort." Is it possible to sort photos manually?
-
Radio Interface Reset and Shutdown Frequently
As recently new office from end-Sept, we have found that the radio interface reset very frequently which has been happening about over 15 times within 8 weeks for one AP on average. Some of those (3 AP so far) got the radio interface down eventuall