• 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

JSF Rendered attribute question

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am migrating a dhtml/ajax/spring web app to jsf on the front-end and am running into the following problem.

We have fields that are optionally rendered depending on a conditional flag that comes off the backend.



The bean is implmented as follows:




But the problem I have is within this method determining what form element has currently executed the method. Am I using the wrong approach here should I be using a phase listener not sure as new to JSF but any help much appreciated.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JR

I used the tag:

<a4j:actionparam name="desc#{rowIndex}ID" value="#{rowIndex}" assignTo="#{DescriptionHandler.rowUpdated}" />

to tell the backing bean what component in a list was clicked (ie the setter for rowUpdated is called).
I think you can get core functionality (if you're not using a4j) from the tags:

f:attribute

or

f:param

Amy
 
J Ruing
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using core tag libs for now and have played around with f:param and f:attribute as far as I can see:

f:param is used on a link or button to append additional info to the request

f:attribute (name/value) to be use to place addtional information into a individual UIComponent

both of these tags will not help - as within the method I don't know what component is exactly executing the call.

Thanks for the prompt reply - I am using a phase listener as I think this will allow me to do what I need.
 
Amy Saari
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But that was the point

pass the id of the component to the backing bean inside the inputText tag.

<f:param name="currentId" value="officeEmail" binding="#{myClass.currentId}" />


String currentId;

public void setCurrentId(String s) {
currentId = s;
}

UIComponent field = fc.getViewRoot().findComponent(currentId);
 
J Ruing
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done as you suggested:



but on the bean the currentId is not a string it is an instance of

"getCurrentId()"= "javax.faces.component.UIParameter@1a06d8b" ???
 
J Ruing
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you have said is not correct when you have a list of fields the param value is always the last one so your suggestion is useless.
 
Amy Saari
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JR

I used ajax4jsf - so our examples aren't exactly the same. I think you have to tell JSF about this property inside this bean in the faces-config.xml inside the managed-bean tag. See:

webpage

See if this helps - I'd be interested to know if that's the problem...

Amy
 
J Ruing
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if the link posted previously is of any value as it relates to updating a jsf component based on user interaction this is not what I am trying to do. I will attempt to outline the problem domain:

Problem:
I have a jsf page that before it loads in the browser I would like to exclude certain fields from being rendered in the response. Sounds fine if I had a traditional backing bean but this is not the case. The application is dhtml and js using ajax requests to get data back from the server - I don't want to change this for now but want the advanages of using the jsf component libs.

We have a client that does not want 3 fields on a particular form so I decided to convert this form to a jsf document so that I could use the jsf panel and the response would render fine no need for me to code the client to ensure that there was no gaps in the form. I have attempted to use the rendered attribute but this has not worked. I have coded a PhaseListener that gets me most of the way it excludes the 3 fields from the form but only after the inital request has been served, i.e. only on second request. I have played around with all the different phase types but none seem to be able to take the 3 fields out of the inital client response. If anyone was any ideas on how to manipulate the component tree for the initial request and render the response please let me know.

Thanks,

JR.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic