I am working on a web-application in jsf.
My question is regarding the working of <h:commandLink>
.
I tried using <h:commandLink>
for doing the stuff which I can do with <h:outputLink>
, just for testing.(I know it is a bad idea to use <h:commandLink>
for static navigation).
My <h:commandLink>
is present in a file called CustomerRight.jsp.
So in my file CustomerRight.jsp, I have the code as shown below:
<f:view>
<h:commandLink action="/pages/accountSettings/ToggleMessageService.jsp" value="Click here"></h:commandLink>
</f:view>
Now this file is included in another jsp called Home.jsp as shown below:
<f:view>
<h:form>
<jsp:include page="CustomerRight.jsp"></jsp:include>
</h:form>
</f:view>
Now as we can see when the page is included in Home.jsp, it will act as a nested <f:view>
tag.
Because of this, the <h:commandLink>
is not working. It is re-deirecting me to the same page, whereas if I use a <h:outputLink>
instead of it, that is working fine.
Can anyone explain me why the <h:commandLink>
is not working but the <h:outputLink>
is working in case of nested <f:view>
tag?
If I remove the <f:view>
tag from the CustomerRight.jsp, the commandLink works fine (since there is no nested <f:view>
tag now)
Also what is the significance of <f:view>
tag? If I don't use it at all in any of the jsps, the page is not rendered. I get an exception saying "java.lang.IllegalStateException: Component javax.faces.component.UIViewRoot@1226eca not expected type. Expected: javax.faces.component.UIOutput. Perhaps you're missing a tag?"