views:

210

answers:

1

Can i somehow add JSF tags to my JSF component renderer class? I'm trying in this way:

        writer.append("<f:param name=\"active\" value=\""+tabName+"\"/>");

But, this tag is not recognized by compiler as JSF tag.

+1  A: 

Adding JSF tag in renderer which is invoked in Renderer response phase is too late and won't work. You need to modify components tree in java or override renderer according what you want to do.

EDIT after comment
So you do this in jsf page like in this example. You need to notice that <f:param> need to be a child element of <h:commandLink> tag. I think your question is about to how to pass parameters to next page. This can be done by creating appropriate <f:param> way, or ususing hidden inputs fields like you do in Struts. In both cases you need to have field in backing bean to store the value or get it from request.

cetnar
Yurish
@Yurish - if you are trying to add parameters to the `<form>` action URL, you may find this difficult. See this answer: http://stackoverflow.com/questions/1560601/navigation-in-java-server-faces-redirecting-with-correct-paramters and perhaps this one: http://stackoverflow.com/questions/1526299/creating-an-edit-my-item-page-in-java-server-faces-with-facelets
McDowell
@cetnar - Yurish stated that he can't use JavaScript, but `h:commandLink` requires it (there is no other way to submit a form using an `<a...` anchor).
McDowell
@McDowell Thanks. @Yourish Why can't you use javascript?
cetnar
Maybe you have ideas, how to do it right way? Maybe, using Javascript. I'm new to JSF. Can't get that logic, how parameters are passed in JSF.
Yurish
@Yurish. @passing parameters - look at example I included in my answer and links pasted by McDowell.
cetnar
@Yurish - it might be best if you post a question outlining what you want to achieve (the logic you want to invoke; the results you want to display) rather than starting with the mechanism you want to achieve them by. The mechanics of Struts may not apply when doing the same thing in JSF.
McDowell