jsf - Best way to check for record existence in editor form -
i'd implement record detail page, user can call using url like:
http://somewhere.foo/detail.jsf?recordid=1
now if record specified identfier can found, actual editor page should displayed, if cannot found error page should displayed instead.
what's best way achieve behaviour using jsf 2.0 , facelets?
i thought of (in pseudocode):
detail.xhtml
<if #{!recordbean.recordfound}> <ui:include detailnotfound.xhtml> <else> ... show regular edit form here ... <endif>
are better or "more accepted" ways of doing this?
use rendered
attribtue this. assuming #{recordbean.list}
returns list
, here's example:
<h:panelgroup rendered="#{empty recordbean.list}"> <ui:include src="detailnotfound.xhtml" /> </h:panelgroup> <h:panelgroup rendered="#{not empty recordbean.list}"> ... </h:panelgroup>
or, if both include pages, use conditional operator ?:
straight in src of ui:include
:
<ui:include src="#{empty recordbean.list ? 'detailnotfound.xhtml' : 'showdetails.xhtml'}" />
for case you're interested, here more examples of possible boolean conditions in rendered
attribute:
<h:somecomponent rendered="#{bean.booleanvalue}" /> <h:somecomponent rendered="#{bean.intvalue > 10}" /> <h:somecomponent rendered="#{bean.objectvalue == null}" /> <h:somecomponent rendered="#{bean.stringvalue != 'somevalue'}" /> <h:somecomponent rendered="#{!empty bean.collectionvalue}" /> <h:somecomponent rendered="#{!bean.booleanvalue , bean.intvalue != 0}" /> <h:somecomponent rendered="#{bean.enumvalue == 'one' or bean.enumvalue == 'two'}" />
Comments
Post a Comment