Hi all,
I am a newbie struggling to build my first BB application. Things are slowly falling into place but I have some issues trying to implement a search field (the app I am writing should be a custom contacts/address book thingie).
Retrieving data from a RecordStore and displaying it was relatively simple but somehow I could not get my text field to accept any characters?
On this forum I found this example: link to this forum, developer-forum/12953-example-edit-fields-buttons.html
I got this working on the simulator in no time so I figured I could take a similar approach in my own code. Too bad, it did not work.
My code is below. Some classes are not displayed but these are
RelatieReadWrite => to read/write/create/delete/close etc. a RecordStore
RelatieReference => a reference Object to hold a record from the RecordStore read in RelatieReadWrite.
HeaderFieldManager => field manager to enable mutliple fields on a single line and play around with colours etc.
RowFieldManager => see HeaderFieldManager
I did try to add the AutoTextEditField (and only that) directly to the screen but this did not change a thing so I don't think it is an issue with the field managers.
Very likely I am simply overlooking something small but if anyone could give me hint on what it is, please do so
Thanks in advance & cheers,
Michiel
PHP Code:
package com.aedificomm.client.csp_mobile;
//import com.rim.samples.device.resource.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.i18n.*;
import net.rim.device.api.system.*;
import com.aedificomm.domino.relation.RelatieReference;
import com.aedificomm.domino.Constants;
import net.rim.device.api.collection.util.*;
/**
* <p>The HelloWorld sample demonstrates some of the most basic features
* of the RIM UI and internationalization (i18n).
*/
public class CspMobile extends UiApplication implements FieldChangeListener
{
private AutoTextEditField searchField; //define the edit fields
private LabelField appTitle; //application title label
private boolean DEBUG = true;
private ButtonField searchButton; //define the buttons
//statics ------------------------------------------------------------------
public static void main(Stringxxx91;xxx93; args)
{
CspMobile theApp = new CspMobile();
//To make the application enter the event thread and start processing messages, we invoke the enterEventDispatcher method
theApp.enterEventDispatcher();
}
/**
* <p>the default constructor. Creates all the RIM UI components and pushes the application's root screen onto the UI stack
*/
public CspMobile()
{
//Push the main screen instance onto the UI stack for rendering.
searchField = new AutoTextEditField("search: ", "");
RelationListScreen rScreen = new RelationListScreen();
Manager searchFieldManager = new HeaderFieldManager(new intxxx91;xxx93; {220, Display.getWidth()-220}, 30, 0);
Manager headerFieldManager = new HeaderFieldManager(new intxxx91;xxx93; {160, Display.getWidth()-160}, 30, 0);
Manager rowFieldManager = new RowFieldManager(new intxxx91;xxx93; {160, Display.getWidth()-160}, 30, 0);
searchFieldManager.add(searchField);
searchButton = new ButtonField("search");
searchFieldManager.add(searchButton);
headerFieldManager.add(new LabelField("NAME", Field.FIELD_LEFT | Field.FIELD_VCENTER));
headerFieldManager.add(new LabelField("SHORTNAME", Field.FIELD_LEFT | Field.FIELD_VCENTER));
RelatieReference rr = new RelatieReference();
TestData td = new TestData();
rr = td.getRR();
try {
RelatieReadWrite rrw = new RelatieReadWrite();
if (DEBUG) {
rrw.write(rr);
}
rr = null;
td = null;
td = new TestData(1);
rr = td.getRR();
if (DEBUG) {
rrw.write(rr);
}
RelatieReferencexxx91;xxx93; values = rrw.read();
rr = null;
int counter = 0;
while (counter < values.length) {
rr = (RelatieReference) valuesxxx91;counterxxx93;;
rowFieldManager.add(new LabelField(rr.getNaam(), Field.FIELD_LEFT | Field.FIELD_VCENTER));
rowFieldManager.add(new LabelField(rr.getNaamKort(), Field.FIELD_LEFT | Field.FIELD_VCENTER));
counter++;
}
if (DEBUG) {
rrw.closeRecStore();
rrw.deleteRecStore();
}
} catch (Exception err) {
System.out.println("xxx91;RelationListScreen::DEBUGxxx93; init RelatieReadWrite mislukt");
System.out.println("xxx91;RelationListScreen::DEBUGxxx93; fout is: " + err.getMessage());
System.out.println("xxx91;RelationListScreen::DEBUGxxx93; fout is: ");
err.printStackTrace();
System.out.println("xxx91;RelationListScreen::DEBUGxxx93; fout is: " + err.toString());
}
rScreen.add(searchFieldManager);
rScreen.add(headerFieldManager);
rScreen.add(rowFieldManager);
pushScreen(rScreen);
}
public void fieldChanged(Field field, int context) //respond to button events
{
if (field == searchButton) //if first button selected
{
Dialog.alert(searchField.getText()); //show text from first input field
}
}
}