In my application, I have a grid populated with some data, I am displaying 2 columns in the grid..ie, name and noOfScripts. But when I double click on the grid, I want scriptname and parameters also to be displayed( and the number of times it is displayed is based on the noOfScripts) in the Window/Form.
I am using Java Servlets for the backend, Now I am not sure if I have to add the script details into the same Main Class or not? How should I handle the script details?
Check this: this is how I add these data:
Here
Should I save scriptname and parameters along with the main data?
Is it possible to store multiple values, if I add scriptname and parameters to the main Store? or should I create a different store for Script?
If I am creating a different store called Scripts..How I should be mapping it to the data record? Are there any methods provided by ExtJs that helps achieve this?
Not sure If my explanation on the problem is clear or not. Do let me know if it is not clear, I will try to make it clear.
Please suggest me if there is something helpful. Any suggestions, ideas or references will help.
Thanks in advance
I suggest you to create a model and a store for Script and on rowitem click - populate a window with the data from the Script store.
ExtJS4 has support for model association (more here) but the mechanism is too complex so i prefer a simplier take on it:
Add MainModelId to Script model and simply filter the Script store every time you show your modal window (grid item click)
Related
I am building an app include edit text and button. The user can put text in the edit text, then click button to transfer him to the browser.
So, I would like to create other layout as recent to store the text that the user entered on the edit text.
How I can do that? I need the logic or code that can help me!
Also, should I have create database to store the data?
Example:
enter image description here
You can store data in multiple ways, and you will need to understand what is right for your use case. You can store data in memory, by simply creating a List with your data type and adding to it every time user will click a button, but then it will not persist between sessions with the app.
If you want the data to persist, then you would need to use permanent storage, and there are a lot of options here:
You could use Shared Preferences
You could use File System and save the data to a file
You could use a database i.e SQLite, and store data there
You could use external server, and get the data through REST API.
Generally, there is a good overview of data storage in Android in the documentation which also have code examples.
Every option comes in multiple ways to accomplish it. There are built-in solutions, and multiple libraries to help you with this task, but first of all, you will need to understand what is the predicted usage of this data. I.E Should user have access to the data from another device? Should the data be available offline? Will data have complex structure? How the app can expand in the future? e.t.c.
Only by knowing this you can design how you will handle it.
If you need logic or code to create view, then you will need ListView, or RecyclerView, Adapter for handling the data, extra xml layout file for single item of your data.
I am coding a questionbank with netbeans as a school project. I am using a JFrame GUI to enter question data. I need some clever way to store, edit and delete data in some file. I donĀ“t want to use any databases. I already tried solving this with txt files but it is tedious and wont work. I need some option where I can add an entire question to the file and then when I retrieve it retrieve certain parts. The data below is how I tried solving it. I then used a scanner to read the files line by line and stop everytime a "_" is read. Is there any better way to store this. Or can i store this in a 2 dimensional array in the java program itself.If so any help or solution is appreciated
Geography_What is England's capital_Berlin_Manchester_Dover_London_D_3
Maths_What is 2+3_7_9_5_6_C_1
Economics_What is demand_idk_stuff_demand_supply_C_2
Well, if you dont want databases or any external files, the only way to "store" information is to create some data structures to do so. The issue with that is they wont persist past the lifetime of the current running application.
Id advise to use some form of external file, or set up a simple sql db. Its easy and will make the project simpler
I am trying to recall a list of employees from an array in Java. I can either choose to do them individually via their ID number or bring all employee info up at once. I know how to code everything else but I cannot find a clear tutorial on how to recall the data and project it onto the text box I have programmed into my GUI. I have the array already created in a different class but I need to get the information from that one and display it in the GUI. Any help would be appreciated. Thanks.
If you want more info just let me know.
[The image is a screenshot of the simple GUI I made.]
There are many ways to do this, but one simple way that may help you to understand this process is as follows:
Implement a store method that simply writes all data to a file in a format of your choice. XML is common, as is TSV or CSV. Some of those are very easy to use, as predefined classes exist to handle them partially or completely.
You will have to read the data you want to store from whereever you have it in your application, possibly in the text boxes directly.
Accordingly implement a restore method that reads the file and fills it back into your data structure and/or the text boxes.
I am currently developing a program with Java that collect and illustrate IP traffic from similar information and draw the graph of this information.
So I must use rrd4j rrd with java to save the data flow from a JTable in another table first and then use RRDTool to draw the graph .
but my problem is how to have the info stored in rrd and also how to create database RRD4J
thank you
First of all I would check rrd4j project home page and check some documentation. On the main page there is usage example of how you create the database and I think it's quite clear and no needed to be explained, since it would be copy+paste.
Now what about storing the information.. First of all you need to define how much and what type of data you want to store. For example in the project I'm working, we are aggregating data daily, weekly, monthly and yearly. You also need to specify what is the frequence of data collection: because it really makes difference if it's 5 seconds or 5 minutes.
You should also have a look at former rrd project homepage and ganglia, the part where you defining the RRD files creation, it will really help you to understand how RRDTool and data storing works.
I'm wandering myself what component is the best for displaying fast search results in swing. I want to create something like this, make a text field where user can enter some text, during his entering I'll improve in back end fast search on database, and I want to show data bellow the text box, and he will be able to browse the results and on pres enter result will be displayed in table. So my question is is there any component which already have this logic for displaying?
Or is it's not, what is the best way to implement that.
This search will be something what ajax gives me on web, same logic same look and feel, if it's possible on desktop application.
Are you looking for something like an AutoComplete component for Java Swing?
SwingX has such a component. See here for the JavaDoc. It has a lot of utility methods to do various things, i.e. auto-completing a text box from the contents of a JList.
I strongly, strongly recommend that you take a look at Glazed Lists - this is one of the finer open source Java libraries out there, and it makes the bulk of what you are asking about super easy.
You will have to first attach a listener to the JTextFields Document to be notified whenever the user types in the field (or changes it).
From there, you can fire off any server-side code you need. The results of that can be used to update a listbox.
A few things to keep in mind:
The code to do the search against the backend must be in another thread
The code that updates the list box should update the list box's model
You will need to manage all your backend search results so that you only update the listbox with the most recent result (e.g. user types 'A', backenf searches for that. Meanwhile, user has typed 'C', kicking off a backend search for 'AC'. You need to ensure the results from the 'A' search dont' make it to the listbox if the 'AC' search results are available).
Use Hibernate Search.
The SwingHack (http://oreilly.com/catalog/9780596009076/) book has an example of this.
In the interest of killing two birds with one stone: have a separate indexing thread. This will:
Improve the speed of searches whenever they are executed.
Improve the responsiveness of the UI since indexing is happening in a separate thread.
Of course, exactly how you perform the indexing will vary widely depending on your particular application. Here is a good place to start researching: Search Indexing. And please, ignore the reference to Web 3.0 [sic].
It is possible of course. It is simple too. For drop down list of terms just use popup menu. This is simple. The background processing of entered text is simple too. Enjoy!