• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing parameters with h: link

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I am trying to do is pass the id of a bean as a parameter to another JSF page and in this site and through the id can display the attributes of the bean

The id is in a table



The id of this bean is received on another website xhtml



This is the bean and entity





The problem is that only the ID passed as a parameter, I would like to pass all the parameters of the Bean, once did with just the ID, but now I think I changed something and isn't does

Watch

Page 1: Object 7 selected



Page 2: Only show the ID of th Object 7 and data sample corresponds to the last item added



Page 3: Here you can see



Is it possible to pass an entire object as a parameter with only the ID?

Help please !!!
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cesar,

I'm not sure as to whether or not you can pass a whole bean as a param, but there may be a much easier way to do what you are trying to do using a data binding on the h:dataTable.


Try something like this:



in PersonalBean:




Now, a couple of clarifications. managedItem needs to be a managed property of PersonalBean, and point towards the actual managed bean of whatever type it is. You are using the newer style declarations, but with the old faces-config style it would look like this:



Please let me know if this helps or if you get stuck at all.

John
 
cesar vasde
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry sometimes incorporated h: commandButton and when I click on them slow to load. What is this?

I would also like to know how to capture data about InputText

For the moment I'm trying to do with this form, in which values are displayed to edit





But I have noticed that when I edit the text boxes are not stored in the bean attribute

Another alternative that I think is through GET with h:link

I took the parameters to a xhtml page and then before rendering the page, through a f:event do a redirect event

What should ahcer to be saved?


Thanks for the help
 
John Tannel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't speak as to why the commandButtons are slow to load, except maybe you are doing too much work with them. For any displayed value, the getter should retrieve a cached value because sometimes during the lifecycle they can be called many times. For example if you are retrieving a list from a db and displaying it, make sure you are returning a cache value of the list, and updating only once or when needed. Otherwise you may go to the database 5 times or more.

Also remember that an h:dataTable is used to display some type of list. The value attribute should point to some kind of list of objects. var is the name of the variable to represent each item from the list in the "loop".

Then within the datatable, your columns should be using values like p.propertyName

It is possible to allow these values to be editable straight from the dataTable but unless this is an important part of the project it may be much easier for you to simply add an 'edit' command button and allow the editing to be done to only a single item at a time on a different page.

As far as I know, to capture data within a dataTable you must use a binding for each field and bind them to a UIInput in the bean that has the Data binding. Then you can iterate through the UIData by selecting each row and it will change which control that each UIInput in the bean points to. To clarify, you have a set of UIInputs in the bean, one for each field. When you have UIData on the first row, the UIInputs will all point to the appropriate fields for the first item from the list. When you change UIData to the second row, they will then point to the ones for the second item on the list. When we did it, we were forced to validate and update values ourselves and could not find a way to make the lifecycle handle this for us. I may be wrong on this account, but I don't know a better way to do it so unless it's critical I always leave editing to another page (which I find to be less error prone on the user's behalf anyways).

To edit on another page, follow my previous instructions and return an appropriate action to forward you to a page that will allow you to edit the selected row.

I hope this helps.

John
 
cesar vasde
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How I can verify that the data be cached?

I tried to implement the option of editing with the suggestion you gave me but the page takes to load
 
John Tannel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cesar,

It really depends what the data is, and where it is coming from. In one application, where we got data from the database and that data would only very rarely change (say a list of states, or items) for a list we used a lazy evaluation. On construction and a clear method call we would set the list to null. On the get method for the list, we would check if it was null. If it IS null we would populate the list. If not, we would return the list.

On my current project, where the list might change a bit more often at least for the user I use a a different method. The website owners have a dynamic content management system I built where they can add/edit/delete items that are displayed. The lists update the first time they are needed, and afterwards are updated whenever a change is made. For any arbitrary list, the list is updated via the lazy evaluation I explained earlier. They are further updated whenever we do an add/edit/delete to the database for that particular list.

The getter methods just return the list which is kept in memory, but I make sure the lists update immediately whenever a change is made. Although this may cause updates that are not needed(for example, if the user updates a list and then immediately logs off), it ends up with less updates overall.

You may want to use something simpler. For example, the action that navigates to the page in question may, as a side affect, call something like 'updateMyList' and then return the navigation action to move to the page that uses the list. Then on the page itself, just return the list that is now updated, don't update at that step. Try putting in some debugging print statements. Find out where the work is being done (for example where you actually connect to the database) and put System.out.println("Calling database to retrieve data for list"); Watch how many times it is actually called on page load. In my database connection code, I print a simple statement: Db connection established. Then as I navigate I can watch how many times i connect to the database. Once the project is ready for production I go back through and clean out these statements.

Best of luck

John
 
cesar vasde
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, here again

Here I have the form implemented with h: commandLink. This is the index-pers.xhtml




The Bean



The modificar.xhtml



The structure of the project



At the end happens this



Sorry for the inconvenience n_n
 
John Tannel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cesar,

You are very close. There are some things that I do not see though. In your picture, there is a modificar button but in your code I see no button. Since you are using a commandLink on the ID, that will work fine and you do not need to have a button.


Checklist:

Inside of your faces-config.xml do you have a navigation rule from index-pers.xhtml to modificar.xhtml for the action 'modificar'?
Inside the bean, change private UIData data =new UIData(); to private UIData data; (I don't think this is a problem, but I know 100% that it works the second way).
MAKE SURE that data is a managed property of PersonalBean. I think this may be your problem.

Here is some managed property info: http://mkblog.exadel.com/2009/08/learning-jsf2-managed-beans/
Read the part about "Dependency Injection"

Try to fix all these. If it still doesn't work, report back and tell me exactly what you are doing to cause it to hang. Also can you show the code in PersonalBean that returns the list?

John

 
cesar vasde
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Tannel wrote:

Inside of your faces-config.xml do you have a navigation rule from index-pers.xhtml to modificar.xhtml for the action 'modificar'?


Inside the bean, change private UIData data =new UIData(); to private UIData data; (I don't think this is a problem, but I know 100% that it works the second way).
MAKE SURE that data is a managed property of PersonalBean. I think this may be your problem.

Here is some managed property info: http://mkblog.exadel.com/2009/08/learning-jsf2-managed-beans/
Read the part about "Dependency Injection"





Then the face-config.xml should look like



Or so



But both does not work



This code of the list



With this method I get the list of index-pers.xhtml
 
John Tannel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cesar,

I'm sorry. I gave you wrong info and didn't realize it until I saw your code. data should NOT be a managed property, I'm sorry. The data property is bound to the data in the h:dataTable from the code there. You can remove that managed property from faces-config.

As for what is not working, I'm not sure at the moment. I'm in the middle of something right now but in an hour I'll look over again and see if I can find the error. Do you get any errors printed at all, even in the tomcat logs? Or does it just hang on that page and do nothing? Try adding in some print statements to debug to make sure all the code executes.

John

Also, do you have Skype, MSN or AIM. It might be easier to discuss on there. Please PM me that info if you do.


 
cesar vasde
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Tannel wrote:Cesar,

I'm sorry. I gave you wrong info and didn't realize it until I saw your code. data should NOT be a managed property, I'm sorry. The data property is bound to the data in the h:dataTable from the code there. You can remove that managed property from faces-config.



When I do that, I get an error message from Eclipse

John Tannel wrote:
As for what is not working, I'm not sure at the moment. I'm in the middle of something right now but in an hour I'll look over again and see if I can find the error. Do you get any errors printed at all, even in the tomcat logs? Or does it just hang on that page and do nothing? Try adding in some print statements to debug to make sure all the code executes.




I'm not get any error message Eclipse or Tomcat.

Simply hangs

I think I better share the code and how I could best help


http://www.megaupload.com/?d=HSSNXP6Z

And database

http://www.megaupload.com/?d=FLJU0LLT
 
cesar vasde
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyone who has tried my code?

I need urgent help please

I'm debugging the application according to this example
And I get the following output



What does this mean?
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic