Search Results

Search found 799 results on 32 pages for 'textfield'.

Page 10/32 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Django: How can I delete a formset entry if one of it's data is blank?

    - by mkret
    Hi, I have the following scenario: I have a form with data that does not need translation and a formset with a textfield that should be translated into an undefined amount of languages. Both parts are bound to a model. Each translated text is kept in a model with a foreign key that binds it to the untranslatable data. Something like: class Person(models.Model): name = models.CharField(max_length=60) birth_date = models.DateField() class PersonBio(models.Model): person = models.ForeignKey(Person) locale = models.CharField(max_length=10) bio = models.TextField() Each form in the formset has 2 fields: A textfield (with the translated text) A locale field (with the language into which the text was translated) I've got it working with no problems until I tryed to change it's normal behaviour. I wanted to eliminate the need for the DELETE field by deleting an instance of the translated text if the textfield was left blank. I've googled quite a lot now and read the whole documentation for forms, formsets and model validation but had no luck. To be honest, I couldn't even think of a solution. Where should I implement this? On a Form clean() method? On the view? Somewhere in the Fieldset? Fieldset's save() method, maybe? I'll keep trying to find a way to do that, but any help/tip/clue is appreciated. Thanks in advance.

    Read the article

  • How do I edit a row in NSTableView to allow deleting the data in that row and replacing with new d

    - by lampShade
    I'm building a to-do-list application and I want to be able to edit the entries in the table and replace them with new entries. I'm close to being able to do what I want but not quit. Here is my code so far: /* IBOutlet NSTextField *textField; IBOutlet NSTabView *tableView; IBOutlet NSButton *button; NSMutableArray *myArray; */ #import "AppController.h" @implementation AppController -(IBAction)addNewItem:(id)sender { [myArray addObject:[textField stringValue]]; [tableView reloadData]; } - (int)numberOfRowsInTableView:(NSTableView *)aTableView { return [myArray count]; } - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return [myArray objectAtIndex:rowIndex]; } - (id)init { [super init]; myArray = [[NSMutableArray alloc] init]; return self; } -(IBAction)removeItem:(id)sender { NSLog(@"This is the index of the selected row: %d",[tableView selectedRow]); NSLog(@"the clicked row is %d",[tableView clickedRow]); [myArray replaceObjectAtIndex:[tableView selectedRow] withObject:[textField stringValue]]; [myArray addObject:[textField stringValue]]; //[tableView reloadData]; } @end

    Read the article

  • Changing JTextArea to JScrollPane Causes it to not be visible

    - by user1806716
    I am having an issue with JScrollPanes and JTextArea objects and getting them to work together. If I just add a JTextArea to my JPanel, it works fine and shows up where I tell it to. However, if I change the contentPane.add(textArea) to contentPane.add(new JScrollPane(textArea)), the textArea is not longer visible and there is no sign of the textarea either. Here is my code: public docToolGUI() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 611, 487); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); textField = new JTextField(); textField.setBounds(253, 323, 86, 20); contentPane.add(textField); textField.setColumns(10); JLabel lblEnterRootDirectory = new JLabel("Enter Root Directory"); lblEnterRootDirectory.setBounds(253, 293, 127, 20); contentPane.add(lblEnterRootDirectory); JButton btnGo = new JButton("Go"); btnGo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { new ToolWorker().execute(); } }); btnGo.setBounds(253, 361, 89, 23); contentPane.add(btnGo); textArea = new JTextArea(); textArea.setWrapStyleWord(true); textArea.setEditable(false); textArea.setBounds(25, 11, 560, 276); contentPane.add(new JScrollPane(textArea)); }

    Read the article

  • How to manage feeds with subclassed object in Django 1.2?

    - by Matteo
    Hi, I'm trying to generate a feed rss from a model like this one, selecting all the Entry objects: from django.db import models from django.contrib.sites.models import Site from django.contrib.auth.models import User from imagekit.models import ImageModel import datetime class Entry(ImageModel): date_pub = models.DateTimeField(default=datetime.datetime.now) author = models.ForeignKey(User) via = models.URLField(blank=True) comments_allowed = models.BooleanField(default=True) icon = models.ImageField(upload_to='icon/',blank=True) class IKOptions: spec_module = 'journal.icon_specs' cache_dir = 'icon/resized' image_field = 'icon' class Post(Entry): title = models.CharField(max_length=200) description = models.TextField() slug = models.SlugField(unique=True) def __unicode__(self): return self.title class Photo(Entry): alt = models.CharField(max_length=200) description = models.TextField(blank=True) original = models.ImageField(upload_to='photo/') class IKOptions: spec_module = 'journal.photo_specs' cache_dir = 'photo/resized' image_field = 'original' def __unicode__(self): return self.alt class Quote(Entry): blockquote = models.TextField() cite = models.TextField(blank=True) def __unicode__(self): return self.blockquote When I use the render_to_response in my views I simply call: def get_journal_entries(request): entries = Entry.objects.all().order_by('-date_pub') return render_to_response('journal/entries.html', {'entries':entries}) And then I use a conditional template to render the right snippets of html: {% extends "base.html" %} {% block main %} <hr> {% for entry in entries %} {% if entry.post %}[...]{% endif %}[...] But I cannot do the same with the Feed Framework in django 1.2... Any suggestion, please?

    Read the article

  • getting nullpointer exception when click on button

    - by user1315187
    I am use a button and when u click this button a text field is automatic created and button status is automatic disable but if u click on disable button text field is automatic delete and button status is changed to enable.i going through this process. public class ConfigurationScreen extends MainScreen implements FieldChangeListener{ TextField tf_text; tf_text = new TextField(TextField.TYPE_PLAIN,img_text[1],img_text[0],TextField.FIELD_HCENTER); tf_text.setWidth(Display.getWidth()/2+20); ImageButton btn_en; btn_en = new ImageButton(imgs_tmintrvl1,"enable",ImageButton.FIELD_HCENTER); ImageButton btn_dis; btn_dis=new ImageButton(imgs_tmintrvl1,"Disable",ImageButton.FIELD_HCENTER); add(btn_en); btn_en.setChangeListener(this); public void fieldChanged(Field field, int context) { if( field==btn_en) { delete(btn_en); insert(btn_dis, 4); insert(tf_text, 5); System.out.println(ex); }else if (field == btn_dis){ delete(btn_dis); delete(tf_text); insert(btn_en, 4); System.out.println("Disable Button="+ex); } } But when i run this code i am getting null pointerr exception please help me where i am making mistake. Thanks in Advance

    Read the article

  • I'm trying to build a to-do-list application in Objective C but coming up short.

    - by lampShade
    I'm getting this error: -[NSCFArray insertObject:atIndex:]: attempt to insert nil Here is the .m file: /* IBOutlet NSTextField *textField; IBOutlet NSTabView *tableView; IBOutlet NSButton *button; NSMutableArray *myArray; */ #import "AppController.h" @implementation AppController -(IBAction)addNewItem:(id)sender { myArray = [[NSMutableArray alloc]init]; tableView = [[NSTableView alloc] init]; [tableView setDataSource:self]; [textField stringValue]; NSString *string = [[NSString alloc] init]; string = [textField stringValue]; [myArray addObject:string]; NSLog(@"%d",[myArray count]); NSLog(@"%@",string); } - (int)numberOfRowsInTableView:(NSTableView *)aTableView { return [myArray count]; } - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { //NSString *data = [myArray objectAtIndex:rowIndex]; return [myArray objectAtIndex:rowIndex]; } @end

    Read the article

  • Why is my NSMutableArray returning nill?

    - by lampShade
    I have a very simple task: add the contents of a textField to an NSMutableArray.The Problem is the array is returning nill. I believe that it has something to do with the fact that the array I'm using is declared as an instance variable. /* IBOutlet NSTextField *textField; IBOutlet NSTabView *tableView; IBOutlet NSButton *button; NSMutableArray *myArray; */ #import "AppController.h" @implementation AppController -(IBAction)addNewItem:(id)sender { NSString *string = [textField stringValue]; NSLog(@"%@",string); [myArray addObject:string]; NSLog(@"%d",[myArray count]);//this outputs 0 why is that? }

    Read the article

  • Watin; Get element by id not working

    - by Afnan
    I am trying to place data into text area that is inside hiden input but watin dose not find it.why? but when i search for inputs my program shows this. var ie = new WatiN.Core.IE("http://facebook.com", true); ie.ClearCookies(); ie.TextField(WatiN.Core.Find.ById("email")).TypeText(textBoxUsername.Text); ie.TextField(WatiN.Core.Find.ById("pass")).TypeText(textBoxPassword.Text); ie.Button(WatiN.Core.Find.ByValue("Login")).Click(); ie.Link(WatiN.Core.Find.ByText("Status")).Click(); ie.TextField(WatiN.Core.Find.ById("u362110_11")).TypeText(textBoxPassword.Text); Exception Could not find INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA element tag matching criteria: Attribute 'id' equals 'u493403_13' at http://www.facebook.com/home.php

    Read the article

  • How can I modify objects inside frames with AS3 in a permanent way?

    - by curro
    I have a MovieClip symbol created with flash in a fla file library. There is a textfield in frame one of this movieclip's timeline . There is another frame in the movieclip timeline. There is a custon class definition for this symbol. It is a flipping card in a memory game. I access the textfield by going to frame 2 (gotoAndStop(2)) and setting the textfield's text property ( this.field.text = "hello" ). However if I go to frame 1 and then return to frame 2, the text becomes the original one in the library's symbol. I have to modify the text propery again in a showFace method I've written. Besides, I cannot pass parameters in the constructor because it is a symbol in the library and that would give errors. I find this behaviour of flash extremely weird. Is there a way I can set properties inside frames permanently? Thank you

    Read the article

  • Django says the "id may not be NULL" but why is it?

    - by Oli
    I'm going crazy today. I just tried to insert a new record and it threw back a "post_blogpost.id may not be NULL" error. Here's my model: class BlogPost(models.Model): title = models.CharField(max_length=100) slug = models.SlugField(max_length=100) who = models.ForeignKey(User, default=1) when = models.DateTimeField() intro = models.TextField(blank=True, null=True) content = models.TextField(blank=True, null=True) counter = models.PositiveIntegerField(default=0) published = models.BooleanField(default=False) css = models.TextField(blank=True, null=True) class Meta: ordering = ('-when', 'id') There are a number of functions beneath the model too but I won't include them in full here. Their names are: content_cache_key, clear_cache, __unicode__, reads, read, processed_content. I'm adding through the admin... And I'm running out of hair.

    Read the article

  • xcode - warning there's no getter/setter for property not even mentioned in the code!!

    - by alexeyndru
    I got the warning : property 'textField' requires method '-textField' to be defined - use @synthesize, @dynamic or provide a method implementation. Now, there is no such property defined in my project! More bizarre, if I just click save in Interface builder and build again, the build is successful - though, right on the line with '@end' the warning appears. Also weird: if I begin to write some code ..and then delete it just the way it was before writing it (maybe not code..anything) and then build&go the warning with the textField appears again. Could be a bug of sdk? What could be happening?

    Read the article

  • Count word occurrences in a text field with LINQ

    - by Yoann. B
    How can i get the occurrences count of a Word in a database text field With LINQ ? Keyword token sample : ASP.NET EDIT 4 : Database Records : Record 1 : [TextField] = "Blah blah blah ASP.NET bli bli bli ASP.NET blu ASP.NET yop yop ASP.NET" Record 2 : [TextField] = "Blah blah blah bli bli bli blu ASP.NET yop yop ASP.NET" Record 3 : [TextField] = "Blah ASP.NET blah ASP.NET blah ASP.NET bli ASP.NET bli bli ASP.NET blu ASP.NET yop yop ASP.NET" So Record 1 Contains 4 occurrence of "ASP.NET" keyword Record 2 Contains 2 occurrence of "ASP.NET" keyword Record 3 Contains 7 occurrence of "ASP.NET" keyword Collection Extraction IList < RecordModel (ordered by word count descending) Record 3 Record 1 Record 2 LinqToSQL should be the best, but LinqToObject too :) NB : No issue about the "." of ASP.NET keyword (this is not the goal if this question)

    Read the article

  • creating button

    - by eomer
    hi I started to learn as3 using fdt i managed to put texts on screen now i want to show the text after the button is clicked but the button does not appear here is the code ` package { import flash.events.MouseEvent; import flash.media.Camera; import mx.controls.Button; import flash.display.Sprite; import flash.text.TextField; public class test2 extends Sprite { private var tField:TextField; public function click(e:MouseEvent):void { tField = new TextField(); tField.text="ffff"; addChild(tField); } public function test2():void { var aa:Button=new Button(); aa.label="deneme"; aa.x=100; aa.y=200; aa.addEventListener(MouseEvent.CLICK, click) } } } ` help me pleaseee

    Read the article

  • How can I access and modify objects inside frames with AS3 in a permanent way?

    - by curro
    I have a MovieClip symbol created with flash in a fla file library. There is a textfield in frame one of this movieclip's timeline . There is another frame in the movieclip timeline. There is a custon class definition for this symbol. It is a flipping card in a memory game. I access the textfield by going to frame 2 (gotoAndStop(2)) and setting the textfield's text property ( this.field.text = "hello" ). However if I go to frame 1 and then return to frame 2, the text becomes the original one in the library's symbol. I have to modify the text propery again in a showFace method I've written. Besides, I cannot pass parameters in the constructor because it is a symbol in the library and that would give errors. I find this behaviour of flash extremely weird. Is there a way I can set properties inside frames permanently? Thank you

    Read the article

  • how do I set a delegate in a view that is not my main view

    - by orangecl4now
    I have a xib. the xib has a button that swaps another xib. the second xib has a uitextfield and a uilabel. how do I make the keyboard go away when I'm done typing? what do I need to wire or code? the second xib has it's own class (called CustomSign.m) Inside CustomSign.m, I've implemented the following method -(void)textFieldDidEndEditing:(UITextField *)textField { [customText resignFirstResponder]; signedLabel.text = customText.text; } - (void)awakeFromNib { //assume textField is an ivar that is connected to the textfield in IB [customText setDelegate:self]; } I get the following warning Class "CustomSign" does not implement the UITextFieldDelegate protocol

    Read the article

  • need code for show result inside table html

    - by klox
    dear all..i have a textfield <tr> <td> <td><input type="text" id="model_name"></td> </td> </tr> and a cell <tr> <td><div id="value">//i want data show here after fill textfield</div> </td> </tr> beside that, i've a table "settingdata" in database it consist of 2 field:itemdata and remark.. itemdata's value are "UD" and remark's value are "FM=87.5-108.0MHZ"... what must i do if i want after type model name "car01UD" at textfield inside <div id="value"></div> can show "FM=87.5-108.0mhz"...

    Read the article

  • how to scroll table on the click event of some cell in objective c?

    - by Sarah
    Hello friends, I am right now working with one application where i need to take one uitableview with uilable and textfield in each cell.I am able to scroll the table manually once the user starts writing, but what i want is that when i click on the textfield,the table should scroll upward so that the user is able to see what he has entered in the textfield.Same thing i saw once i logged in the iphone facebook. this is the code for manually scrolling the table : - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 250; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { CGRect viewRect = CGRectMake(0, 0, 320, 160); UIView *footerView = [[UIView alloc] initWithFrame:viewRect]; return footerView; } Is there any way around? Thanks in advance.

    Read the article

  • Make jquery array out of div

    - by Industrial
    Hi everyone, Each div with the class "row" is added upon request from the user, to be able to add multiple items at once. So now is the question how I'll collect all the forms in to an array that PHP can read (like JSON for instance). I'll guess that there's already some easy and effective way of doing this? <div class="container"> <div class="row"> <input type="text" name="value1" id="textfield" /> <input type="text" name="value2" id="textfield" /> <input type="text" name="value3" id="textfield" /> </div> </div> Here's what I would like to achieve out of the shown example: array( array ('value1' => '', 'value2' => '', 'value3' => '') ); Thanks!

    Read the article

  • What sort of schema can I use to accommodate manual date based data entries?

    - by meder
    I have an admin where users from multiple properties can enter in monthly statistics for twitter/facebook followers. We do not have access to the real data/db so this is why a manual entry. The form looks like this: Type ( radio, select **one** only ): - Twitter - Facebook Followers/Fans ( textfield ): Property (dropdown): Hotel A, Hotel B Date Start: mm/dd/yyyy (textfield) Date End: mm/dd/yyyy (textfield) Question 1.1: Since I am only keeping track of month per month, the date start/end fields which I have already created might be too specific. Would it be a better idea just to have a start month/year and and month/year if that's the only thing I care about? Question 1.2: What schema could I use for month to month statistics if I were to change the date start and end textfields to start month/year and end month/year dropdowns?

    Read the article

  • uitextfield secure

    - by D_R
    I have a UITexetField with "Secure" option enabled in InterfaceBuilder (used to enter a password). Then I try to read, what the user entered. (void)textFieldDidEndEditing:(UITextField *)textField{ NSString *txt = textField.text; int a = 0; } It works fine with iOS 5 but since I use it in iOS6, this method no longer works - neither in simulator, nor at the real device. It was called, but textField.text returns always an empty string. With other UITextFields, without "Secure" option, it works fine. Could somebody help me ?

    Read the article

  • Using MigLayout, why is a JButton following a JTable unresponsive and how to fix this?

    - by M. Joanis
    Hi everyone, I am having a mind-boggling problem regarding the use of a JButton following a JTable with MigLayout. It is totally unresponsive unless I push it far enough past the JTable (then it can behave correctly). I have tried running the code with both the MigLayout JAR of the version we use for end user products and with the very most recent one; same result. Here is a sample code reproducing the problem (Main.java): import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import net.miginfocom.swing.MigLayout; @SuppressWarnings("serial") public class Main extends JFrame { private JPanel panel; private JTextField textField; private JButton chooseButton; private JTable table; private JButton reloadButton; private final DefaultTableModel model = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { return false; } }; public Main() { panel = new JPanel(new MigLayout("debug", "[][grow][]")); setContentPane(panel); setDefaultCloseOperation(EXIT_ON_CLOSE); /*** First row ***/ // "File:" panel.add(new JLabel("File:")); // textField for filename textField = new JTextField("No file selected yet!"); textField.setEditable(false); panel.add(textField, "growx"); // "Choose..." button chooseButton = new JButton("Choose..."); panel.add(chooseButton, "wrap, sg buttons"); /*** Second row ***/ panel.add(new JLabel()); table = new JTable(model); model.setColumnIdentifiers(new String[] {"col title"}); JScrollPane scrollpane = new JScrollPane(table); Dimension scrollpaneDimension = new Dimension(125, 110); scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); table.setPreferredScrollableViewportSize(scrollpaneDimension); table.setFillsViewportHeight(true); panel.add(table.getTableHeader(), "grow"); panel.add(scrollpane, "grow"); reloadButton = new JButton("Reload"); panel.add(reloadButton, "top, wrap, sg buttons"); pack(); setVisible(true); } public static void main(String[] args) { new Main(); } } I suppose it has something to do with the table header and the table itself ending up in the same layout cell, but I'm really not sure of this. As I said, if I push the button far enough past the JTable, it will work again. If I drop it on the next row, it doesn't work, I have to move it down one more row. The only library you need in your workspace to run the code is MigLayout. Thank you all for your help, much appreciated! M. Joanis

    Read the article

  • Form values appear blank when submitting to the database - Drupal FormAPI

    - by GaxZE
    Hello, I have been working on this drupal form API script for past week and half. to give an insight into my problem.. the form below merely lists a host of database records which contain 5 individual scoring ranks. (mind, action, relationship, language and IT). this code is apart of my own custom module where all values are listed from the database. the idea behind this module is to be able to edit these values on a large scale. I am having trouble getting the values entered in the form to be passed to the variables inside of the marli_admin_submit function. the second problem is the assigning those values to their specific ID. for this purpose id like to add im merely trying to get just one score updated rather than all of them. below is my code. any advice appreciated. function marli_scores(){ $result = pager_query(db_rewrite_sql('SELECT * FROM marli WHERE value != " "')); while ($node = db_fetch_object($result)) { $attribute = $node->attribute; $field = $node->field_name; $item = $node->value; $mind = $node->mind; $action = $node->action; $relationship = $node->relationship; $language = $node->language; $it = $node->it; $form['field'][$node->marli_id] = array('#type' => 'markup', '#value' => $field, '#prefix' => '<b>', '#suffix' => '</b>'); $form['title'][$node->marli_id] = array('#type' => 'markup', '#value' => $item, '#prefix' => '<b>', '#suffix' => '</b>'); $form['mind'][$node->marli_id] = array('#type' => 'textfield', '#maxlength' => '1', '#size' => '1', '#value' => $mind); $form['action'][$node->marli_id] = array('#type' => 'textfield', '#maxlength' => '1', '#size' => '1', '#value' => $action); $form['relationship'][$node->marli_id] = array('#type' => 'textfield', '#maxlength' => '1', '#size' => '1', '#value' => $relationship); $form['language'][$node->marli_id] = array('#type' => 'textfield', '#maxlength' => '1', '#size' => '1', '#value' => $language); $form['it'][$node->marli_id] = array('#type' => 'textfield', '#maxlength' => '1', '#size' => '1', '#value' => $it); } $form['pager'] = array('#value' => theme('pager', NULL, 50, 0)); $form['save'] = array('#type' => 'submit', '#value' => t('Save')); $form['#theme'] = 'marli_scores'; return $form; } function marli_admin_submit($form, &$form_state) { $marli_id = 4; $submit_mind = $form_state['values']['mind'][$marli_id]; $submit_action = $form_state['values']['action'][$marli_id]; $submit_relationship = $form_state['values']['relationship'][$marli_id]; $submit_language = $form_state['values']['language'][$marli_id]; $submit_it = $form_state['values']['it'][$marli_id]; $sql_query = "UPDATE {marli} SET mind = %d, action = %d, relationship = %d, language = %d, it = %d WHERE marli_id = %d"; if ($success = db_query($sql_query, $submit_mind, $submit_action, $submit_relationship, $submit_language, $submit_it)) { drupal_set_message(t(' Values have been saved.')); } else { drupal_set_message(t('There was an error saving your data. Please try again.')); } }

    Read the article

  • Problem with evaluating XPath expression in Java

    - by JSteve
    Can somebody help me find the mistake I am doing in evaluating following XPath expression? I want to get all "DataTable" nodes under the node "Model" in my xml through XPath. Here is my XML doc: <?xml version="1.0" encoding="UTF-8"?> <Root> <Application> <Model> <DataSet name="ds" primaryTable="Members" openRows="1"> <DataTable name="Members" openFor="write"> <DataColumn name="id" type="String" mandatory="true" primaryKey="true" valueBy="user"/> <DataColumn name="name" type="String" mandatory="true" valueBy="user"/> <DataColumn name="address" type="String" mandatory="false" valueBy="user"/> <DataColumn name="city" type="String" mandatory="false" valueBy="user"/> <DataColumn name="country" type="String" mandatory="false" valueBy="user"/> </DataTable> </DataSet> </Model> <View> <Composite> <Grid> <Label value="ID:" row="0" column="0" /> <Label value="Name:" row="1" column="0" /> <Label value="Address:" row="2" column="0" /> <Label value="City:" row="3" column="0" /> <Label value="Country:" row="4" column="0" /> <TextField name="txtId" row="0" column="1" /> <TextField name="txtName" row="1" column="1" /> <TextField name="txtAddress" row="2" column="1" /> <TextField name="txtCity" row="3" column="1" /> <TextField name="txtCountry" row="4" column="1" /> </Grid> </Composite> </View> </Application> </Root> Here the Java code to extract required node list: try { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); domFactory.setIgnoringComments(true); domFactory.setIgnoringElementContentWhitespace(true); DocumentBuilder builder = domFactory.newDocumentBuilder(); Document dDoc = builder.parse("D:\TEST\myFile.xml"); XPath xpath = XPathFactory.newInstance().newXPath(); NodeList nl = (NodeList) xpath.evaluate("//Model//DataTable", dDoc, XPathConstants.NODESET); System.out.println(nl.getLength()); }catch (Exception ex) { System.out.println(ex.getMessage()); } There is no problem in loading and parsing xml file and I can see correct nodes in dDoc. Problem is with xpath that returns nothing on evaluating my expression. I tried many other expressions for testing purpose but every time resulting NodeList "nl" does not have any item

    Read the article

  • Java ME scorecard with vector and multiple input fields/screens

    - by proximity
    I have made a scorecard with 5 holes, for each a input field (shots), and a image is shown. The input should be saved into a vector and shown on each hole, eg. hole 2: enter shots, underneath it "total shots: 4" (if you have made 4 shots on hole 1). In the end I would need a sum up of all shots, eg. Hole 1: 4 Hole 2: 3 Hole 3: 2 ... Total: 17 Could someone please help me with this task? { f = new Form("Scorecard"); d = Display.getDisplay(this); mTextField = new TextField("Shots:", "", 2, TextField.NUMERIC); f.append(mTextField); mStatus = new StringItem("Hole 1:", "Par 3, 480m"); f.append(mStatus); try { Image j = Image.createImage("/hole1.png"); ImageItem ii = new ImageItem("", j, 3, "Hole 1"); f.append(ii); } catch (java.io.IOException ioe) {} catch (Exception e) {} f.addCommand(mBackCommand); f.addCommand(mNextCommand); f.addCommand(mExitCommand); f.setCommandListener(this); Display.getDisplay(this).setCurrent(f); } public void startApp() { mBackCommand = new Command("Back", Command.BACK, 0); mNextCommand = new Command("Next", Command.OK, 1); mExitCommand = new Command("Exit", Command.EXIT, 2); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { if (c == mExitCommand) { destroyApp(true); notifyDestroyed(); } else if ( c == mNextCommand) { // -> go to next hole input! save the mTextField input into a vector. } } } ------------------------------ Full code --------------------------------- import java.util.; import javax.microedition.midlet.; import javax.microedition.lcdui.*; public class ScorerMIDlet extends MIDlet implements CommandListener { private Command mExitCommand, mBackCommand, mNextCommand; private Display d; private Form f; private TextField mTextField; private Alert a; private StringItem mHole1; private int b; // repeat holeForm for all five holes and add the input into a vector or array. Display the values in the end after asking for todays date and put todays date in top of the list. Make it possible to go back in the form, eg. hole 3 - hole 2 - hole 1 public void holeForm(int b) { f = new Form("Scorecard"); d = Display.getDisplay(this); mTextField = new TextField("Shots:", "", 2, TextField.NUMERIC); f.append(mTextField); mHole1 = new StringItem("Hole 1:", "Par 5, 480m"); f.append(mHole1); try { Image j = Image.createImage("/hole1.png"); ImageItem ii = new ImageItem("", j, 3, "Hole 1"); f.append(ii); } catch (java.io.IOException ioe) {} catch (Exception e) {} // Set date&time in the end long now = System.currentTimeMillis(); DateField df = new DateField("Playing date:", DateField.DATE_TIME); df.setDate(new Date(now)); f.append(df); f.addCommand(mBackCommand); f.addCommand(mNextCommand); f.addCommand(mExitCommand); f.setCommandListener(this); Display.getDisplay(this).setCurrent(f); } public void startApp() { mBackCommand = new Command("Back", Command.BACK, 0); mNextCommand = new Command("OK-Next", Command.OK, 1); mExitCommand = new Command("Exit", Command.EXIT, 2); b = 0; holeForm(b); } public void pauseApp() {} public void destroyApp(boolean unconditional) {} public void commandAction(Command c, Displayable d) { if (c == mExitCommand) { destroyApp(true); notifyDestroyed(); } else if ( c == mNextCommand) { holeForm(b); } } }

    Read the article

  • Why ((Integer) weightModel.getObject()).intValue(); throws exception

    - by yakup
    I am learning Wicket by "Enjoying Web Development with Wicket" book. And in an example: int weight = ((Integer) weightModel.getObject()).intValue(); is used. When I click Submit button it throws exception. But after changed the code to: int weight=Integer.parseInt( (String) weightModel.getObject()); It works fine. What is the reason for throwing the exception? The full code: GetRequest.java package myapp.postage; import java.util.HashMap; import java.util.Map; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.Model; @SuppressWarnings("unchecked") public class GetRequest extends WebPage { private Model weightModel=new Model(); private Model patronCodeModel=new Model(); private Map patronCodeToDiscount; public GetRequest(){ patronCodeToDiscount=new HashMap(); patronCodeToDiscount.put("p1", new Integer(90)); patronCodeToDiscount.put("p2", new Integer(95)); Form form=new Form("form"){ @Override protected void onSubmit(){ int weight = ((Integer) weightModel.getObject()).intValue(); Integer discount=(Integer)patronCodeToDiscount.get(patronCodeModel.getObject()); int postagePerKg=10; int postage=weight*postagePerKg; if(discount!=null){ postage=postage*discount.intValue()/100; } ShowPostage showPostage=new ShowPostage(postage); setResponsePage(showPostage); } }; TextField weight=new TextField("weight",weightModel); form.add(weight); TextField patronCode=new TextField("patronCode",patronCodeModel); form.add(patronCode); add(form); } } The html file GetRequest.html: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <form wicket:id="form"> <table> <tr> <td>Weight</td> <td><input type="text" wicket:id="weight"/></td> </tr> <tr> <td>Patron code:</td> <td><input type="text" wicket:id="patronCode"/></td> </tr> <tr> <td></td> <td><input type="submit"/></td> </tr> </table> </form> </html>

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >