Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!

Deroga Rivera

Greenhorn
+ Follow
since Aug 04, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Deroga Rivera

I will answer this question myself just in case someone else struggles with the same issue. Passing a parameter from Java to BIRT is a several step process (this may not be the best way but it does work)

Assuming that BIRT is installed with Eclipse and functional try the following:

  • In your report design add a new Report Parameter ( RP_param )
  • In your data set Query create your query with something like "WHERE ID = ?" or some other criteria using a ? for the value.
  • In your data set add a Parameter ( DS_param ) then set the default value of this parameter to the Report Parameter you created earlier (RP_param) to do this click on the default value field then the ... button. In the resulting dialog choose Category 'Report Parameters', sub category 'All' then double click your Report Parameter to add it and click OK.
  • [list]In the Java code do something like
    This will send the value of paramValue to your Report Parameter RP_param which will in turn send the value to the dataset parameter DS_param which will cause the report to run with the proper data.

    [ September 05, 2006: Message edited by: Deroga Rivera ]
    Thanks for all of the great information. As it turns out the job name was stored in the accounting system in such a cryptic way that the boss decided not to use it at all. I did however switch some of the more often used queries over to prepared statements and I was able to use the idea in another area of the application.

    Thanks again.
    13 years ago
    I have a JTable in my application that displays the data in a ResultSet. I also gave the user the ability to filter this list by some of the fields (user,jobNumber, etc).

    Currently the filter causes another database query with a WHERE clause then updates the JTable using model.setResultSet(rs) and model.fireTableDataChanged() calls with the new ResultSet.

    Since the original list contains all of the records I would like to avoid hitting the database a second time just to hide some of the records and a third time just to show what I had originally!

    Is there a way to allow filtering of a ResultSet in a JTable without replacing the ResultSet?

    Thanks!
    13 years ago
    You could either import the other package or fully qualify your call.
    so import user.begin.* and you can get to all your public methods
    13 years ago
    Well the getJobName call is only made after I call the isValidJobNumber method so it would always have a valid job number and it does not handle bad job numbers! That is why I wanted to clean this up.

    I can see the idea of bypassing the isValid routine all together but I am a little fuzzy on how to make that work. Lets say I create a method similar to:



    Assuming that all the database setup is correct that would return a jobName string when the job number is valid or will throw an exception when it is not. I know that jobNumber is the PK so it will either have one record returned or no records at all. So when calling getJobNum I would need to catch the SQLException?



    showInvalidJobNumberError() would display a error dialog requesting that a valid job number be entered before continuing. At which point I would return out of the method and wait for the user to enter a better job number and try again (it is ran from a GUI).

    Does that sound like a more reasonable approach or would you structure it differently?
    13 years ago
    I have been working with a project and would like a bit of advice on how to handle a particular situation. I don't have any problems getting it to work I just want advice on the best way to set it up.

    Here is the situation:
    I have a database that was not created or maintained by me that I cannot make changes to. This database contains a table (jobs) that among other information has two fields, jobNum and jobName.

    My application needs to have a valid job number (determined by its existence in the above table) and if the job number is valid I want to look up the job name.

    This is similar to what I have (without the details):




    I don't really like this scenario because I end up hitting the database twice, once to verify the job number and a second time to get the corresponding job name.

    I also had it where the jobName was set as part of the isValidJobNumber method but I didn't like the dual purpose method so I tried to split them.

    Hopefully someone with more experience in these situations could provide some feedback or advice on handle this scenario in a clean & efficient manner.

    Thanks.
    13 years ago
    I have recently started using BIRT for some very simple reporting in a Java\SQL Server application. By the logic of the application the user will select a certain database record to view (generally a JComboBox of jobNumbers) at this point I want to create a report in BIRT for this jobNumber. I have the basic report design and I can open it from my Java app using IRunAndRender but I can't get a data parameter to work.

    I have a Where jobNum = ? in my dataSet SQL and I can set it up to prompt the user to enter the job number but I want to pass the report the job number that is already displayed on the form the user is looking at (it is in a JTextfield).

    How can I pass a parameter value to the BIRT report so it only displays the correct record?

    Thanks.
    If you manage to set up the mailing list would you please put me on it!

    I think it would be a good idea and I don't agree that simply using a forum is good enough for a timely topic. Unless you follow that particular forum daily, you would miss the notice.

    Just my thoughts.
    14 years ago
    Thanks again for your helpful responses.

    I do understand the concept and usage of polymorphism and have used it in some small applications. I have been programming for awhile at a basic to intermediate level, I just stopped for the last 6 or 8 months so when Java 5 came out I took it as an opportunity to revisit some of the more basic concepts to see them from a different viewpoint. When I got to this I didn't just accept it as I did the first time through!

    ---

    What confuses me about the usage is why someone would do something like
    Date() myDate = new Calendar();
    or
    Employee() emp = new Manager();

    Instead of keeping the class the same on both sides. I realize the power of polymorphism does not need to know if it is an employee or manager but what hasn't sunk in yet is why you wouldn't just use
    Calendar() myDate = new Calendar();
    and
    Manager() emp = new Manager();

    To me, it seems clearer as to what is going on and I can't find an advantage to the other method. Any insight that might help me make sense of that?

    Thanks!
    Deroga.
    14 years ago
    I think there needs to be some better clarification on what type of question falls under beginner and what falls under intermediate. The intermediate forum currently has some really basic questions, about variables, exceptions, etc. While the beginner forum has some topics that are a bit more involved.

    While learning it is hard to know where to rank yourself. One person may feel their questions are intermediate as soon as they figured out how to create their own classes. Another person might feel like a beginner until they have covered every topic in an intro to Java book. Some may always feel that way.

    A warning exists on the beginner forum about posting questions that are too hard, but what is too hard? I could set up my own guidlines on this but they probably won't match with anyone else. It would good to have some more formalized guidlines to follow.

    Just a thought.
    14 years ago
    I know some things won't be clear until I have worked with them for a while longer and continue to think about it in this way. The next time I run across and example like

    SomeClass myName = new SomeOtherClass();

    I will look at it more carefully and try to understand why they chose to do it that way. With the information you gave here I should be able to figure that out.

    Thanks again for all of your help.
    Deroga.
    14 years ago
    I understand the concept of polymorphism, thanks for clarify it.
    ---

    Employee e = new Manager();
    ...
    Manager m = (Manager) e;



    Wouldn't this be the same as Manager m = new Manager();
    ---

    So I guess I understand why it does what it does. What I don't understand is what purpose doing something like Employee em = new Manager() has. I have seen this kind of usage in some code samples, mostly with Date/Calendar classes but I don't understand why anyone would use it.

    If you create an Manager but treat it as an employee you lose the abilities of the manager and you don't appear to gain anything. I understand the concept of having an array of employees and managers and being able to make the same call to either type and have Java figure out what should be done, but what possible advantage could you have with the Employee em = new Manager() type of statement?

    Thanks for the very helpful response, I am getting a handle on this.
    Deroga.
    14 years ago
    I read some of the past forum posts but none of them quite get to what I am trying to figure out. I have the following classes:


    With the following to test a few things:


    I understand the concept of why a manager object uses the getSalary method in the manager class and why an employee will use the employee method.

    I also understand why an employee cannot access manager methods but a manager can access employee methods.

    What I do not understand.
    When I created an Employee and assigned a Manager type to it.
    1. It created an employee, I am ok so far.
    2. It uses the Manager getSalary. I am not ok with this.
    3. Attempts to access the setBonus method in manager fails

    It seems like the instance I called em is both a manager and an employee depending on what it wants to do. I don't understand why it calls the manager getSalary but will not allow code to call manager methods.

    I mark the areas of the code that I don't understand why they act as they do with hopefully that will make it easier to follow.

    Thanks!
    14 years ago