I have a problem I want to use the list and when I click on a component of the list it take me to another form (make an action) meaning if I click on an item from the list depending on the selected index it takes me to another form.
Is this in a GUI builder app or manual app?
For GUI builder use the action event callback for the list see: http://www.codenameone.com/how-do-i---handle-eventsnavigation-in-the-gui-builder--populate-the-form-from-code.html
Then get the index/selected item using:
int index = list.getSelectedIndex();
Object value = list.getSelectedItem();
Then you can show the form you want using:
showForm("FormName", null);
In handcoded apps you can get the selected item/index in exactly the same way then do something like:
form.show();
To show a specific form.
Related
I have to create a collection of buttons dynamically based on lists of words.
I create them with a class.
Then I have to dynamically see how many of them are clicked by the user and act accordingly (get the collection of clicked buttons per column).
My problem is how to deal with the event handlers.
I can not make my mind around as how to deal collectively with all the buttons created. I basically need a listener that every time a change happens looks how many buttons are clicked and of course click and unclick the corresponding buttons.
This is so far my code:
class verticalButtons():
def __init__(self,concepts):
self.verticalbuttons = self.create_buttons(concepts)
def create_buttons(self,concepts):
import ipywidgets
wd_buttons = []
for i,concept in enumerate(concepts):
newbutton = ipywidgets.Button(description=concept,
button_style='success')
wd_buttons.append(newbutton)
verticalbox = VBox(wd_buttons)
return verticalbox
basically passing a list of words to the class creates a VBox with the buttons.
mylist1 = ['1first','1second','1third']
mylist2 = ['2first','2second','2third','2fourth']
one = verticalButtons(mylist1)
two = verticalButtons(mylist2)
button_columns = widgets.HBox([one.verticalbuttons,two.verticalbuttons])
display(button_columns)
the result is as follows:
Some idea? I don't even need the code, but just kind of the idea how to deal with it.
thanks.
I am writing a small experimental desktop application. Basically it has the options to display a list of recipes and detailed information about a single recipe.
To accomplish that i implemented a class called RecipeContext that stores a ObservableList<Recipe> that i bind to a TableView, so the view gets automatically updated if i add to, or remove from the collection.
I want something similar for the single recipe, an Observable where i simply have to change the contained recipe and have the view automatically update to display the new recipe information.
To make this a bit more clear, i want something like this:
SingleObservable<Recipe> detailedRecipe = new SingleObservable<>(new Recipe("A"));
detailedInformationController.bindRecipeObservable(detailedRecipe);
// Recipe A is displayed
detailedRecipe.set(new Recipe("B"));
// View is notified about the change and displays Recipe B
Is there a class that does that?
SimpleObjectProperty will do what you want.
SimpleObjectProperty<Recipe> detailedRecipe = new SimpleObjectProperty<>(new Recipe("A"));
...
detailedRecipe.set(new Recipe("B"));
http://docs.oracle.com/javase/8/javafx/api/javafx/beans/property/SimpleObjectProperty.html
I'm starting a single page app and still haven't chosen any framework. The only complex thing it needs to do is allow the users to select an element from a tree structure for one of the fields of a form. It would be nice if it worked with both mouse selection and keyboard autocomplete. The tree is 5 levels deep and contains around 500 elements. What would be a good way to implement this?
Here's a fiddle to show you how to recursively build a tree: http://jsfiddle.net/KtbXb/ .
As far as input, binding a click function to each node will call a function with access to all data associated with clicked node:
view:
<li data-bind="text: name, click: yourFunction"></li>
viewmodel:
var yourFunction = function (data) {
//your function will have access to the node via data
};
For keyboard input, you can add an input to your view and bind the value to an observable value. From there, you can probably find a substring search algo online, or even a plugin (jquery.table-filter does a good job of this)
I made a model with EMF, representing the settings of a device, and a RCP GUI. In the GUI I have a list to select different devices of the type of the model (Master).
The model has a List of Objects of a small class which should be displayed in a table (Detail).
The tableItems itself need to be edited so I have a small GUI part with checkboxes etc. to change the settings. Here the tableitem is master and all fields shown in the GUI are details.
Observable for the List of devices:
IObservableValue selection = ViewersObservables.observeSingleSelection(availableDevicesList);
Table:
IObservableList list = EMFObservables.observeDetailList(Realm.getDefault(), selection,DevicePackage.Literals.LIST);
TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION);
tableViewer.setInput(list);
IObservableValue tableSelection = ViewersObservables.observeSingleSelection(tableViewer);
Editing:
Spinner field1 = new Spinner(parent, SWT.BORDER);
dbc.bindValue(SWTObservables.observeSelection(field1), EMFObservables.observeDetailValue(Realm.getDefault(), tableSelection, DevicePackage.Literals.Value1));
When changing the device selection the tableitems get replaced. But the tableSelection seems to have a problem with this. Sometimes it still contains values of a a tableitem from a different device and sometimes it just contains null.
I also have a button which gets enabled/disabled according the validation status of all fields. When the tableSelection puts null into these fields the validation does not work and the button is disabled until a entry in the table is selected.
I tried to manually set the selection empty with a listener on the list and:
tableViewer.setSelection(StructuredSelection.EMPTY, true);
but this does not do the full job. At least all "old" values are replaced but the null problem still occurs.
All I need is to set the tableSelection to an empty state as after the launch of the application, when no tableitem was selected yet.
I found the solution by myself. The problem was actually the spinner itself. It threw a nullpointer when the selection was empty and there was no value.
I solved it by giving it a custom converter (from int to int...) where I return a default value if the source is null.
Now the validation works fine and my button's enable state is set correct.
Is there a way to get the selected value (or text, or index) of a select box that the server fills (using ASP.NET) in the client? I've tried $("#ID").val() - but the only time that works is when I continue to another page and then go back. Even then, the value that is returned is the previously selected value - if the user changes the selection, it's not registered unless they leave the page and go back. Go easy on me, I'm new at this...
Update: Tried using a regular html select, same issue (just with a populated entry). Let me elaborate on what I'm trying to do: in a separate page, I'm getting results for an autocomplete search box. The select boxes are for filters. Naturally, if the user selects a filter, I don't want to suggest items that are no longer valid. I'm looking for the keys in the ProcessRequest method of the page that contains autocomplete info.
public override void ProcessRequest(HttpContext context)
{
string respString;
string qsKey = "q";
Customer searchCust = Session[Data.Selected_Customer] as Customer;
Dictionary<string, string> qsDict = context.Request.QueryString.ToDictionary(qsKey);
Shouldn't I get the results (for instance '&ID=foo' on the last line # context.Request.QueryString?
If you want the actual selected item itself:
$("#ID option:selected");
are you sure that 'ID' is really the id of the select box ? been awhile since i used asp.net but i remember it mucked with identifiers a lot
I use the code (below) to manipulate an ASP.NET generated select box. Within the code I obtain the value of the original select box (item). Also consider using the .text() function.
var setValue = function(item){
//if value isn't already selected, postback
if(input.value != item.text())
if(select.attr('onchange'))
eval(select[0].attributes['onchange'].nodeValue);
//set input box value
$(input).val(item.text());
$(input).removeClass('empty');
//select original ASP.NET select value (hidden)
select.val(item.text());
$(lookup).hide();
//show type if present
$('.selectType').show();
};
Hope this helps.