• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with custom input text component inside ui:repeat

 
Val Petcu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I need your help..., please...

I'm in the middle of a migration process from JSF 1.2 to JSF 2.1.

The Implementation I use is Sun's Mojarra implementation with facelets, which in JSF 1.2 were not part of the standard but, since JSF 2.0 they become.

Right now I am using javax.faces.PARTIAL_STATE_SAVING as true. (Tried with false, but none of my custom components worked.)

We have some custom JSF components, and in mosta cases they are workibng fine. However, the folowing exeample is not working correctly:



bf:TextBox is a custom text box which extends HtmlPanelGroup and has 2 custom children components:

A custom label (extanding HtmlOutputlabel) and aa custom input(extending HtmlInputText)


When this component is used without ui:repeat, everithing work fine. However when inside it, problems occur.

In the first renderreponse phase, everything is fine. But when you do a post, in the restoreview phase, the children of the custom HtmlPanelGroup (label and inputText) are not present in the viewRoot, so the values submitted are not present.

The same code snipped was working in the JSF 1.2 correctly.


Thank you all in advance,

Vasilica Petcu


 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Vasilica!

Actually, you've been very lucky. JSF2 is a LOT different internally than JSF1 was. I had a Google Maps custom control that required a massive overhaul.

I see that you appear to be doing a table via brute-force HTML. The first thing I'd recommend is to replace the HTML and loop with a JSF dataTable control. The employment of any sort of logic in a View Template is not something I recommend in the best of circumstances.

The second thing I'd recommend is to consider replacing the custom binary controls with an XML-based custom control definition. XML custom controls are simpler to create and are less likely to break when JSF goes through architectural upgrades.

If neither of the above works for you, I'm afraid you're going to have to read the JSF2 specs on custom controls in detail, because you cannot assume that things work the same as they did in JSF1. In other words, it's going to be about as much work as creating the custom control initially did.

 
Val Petcu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Tim,

Thank you for your reply and sorry for my late answer.

I understand everything what you are saying... but... as there are alot of pages constructed this way... I am trying first to see if I can maintain the pages as they are and just change my custom component(s)...

When I made this post I was hoping there is someone which had the same issue and managed to get a workaround by changing something in ui:repeat or by changing the custom component...


Thank you...
Vasilica Petcu
 
Val Petcu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have found a workaround for my issue. As the main goal was to make minimum changes into application... I avoided changing the all pages that were using ui:repeat. Instead, I have changed my custom component to save the children into State Holder (saveState method) and then I restore the children if the component has a ui:repeat as parent.



this is extracted from saveState method.




this is extracted from restoreState method.




this is the method that checks if component has UIRepeat as parent


Thank you all again...

Vasilica Petcu

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!