0
votes

I am new to JSF and getting very confused doing something trivial. I am making up this example here to elaborate what I am want to do:

I have a xhtml fragment, say, stockQuoteFragment.xhtml, which is backed by a ManagedBean, say, StockQuoteService.java. StockQuoteService.java has property stockID and a method getStockQuote() which has all the logic to get the stockQuote for the value set on stockID property. stockQuoteFragment.xhtml displays #stockQuoteService.stockQuote.

Now I have another page Home.xhtml page with backing bean HomeBackingBean.java with a method getUserFavoriteStockID(). I want to include content of stockQuoteFragment.xhtml in Home.xhtml passing in the value of #homeBackingBean.userFavoriteStockID to StockQuoteService.setStockID().

I am not sure how to do this in JSF/Facelets. With simple JSPs I could do this easily with a JSP include and include parameters

2

2 Answers

0
votes

No.

...According to TLD or attribute directive in tag file, attribute var does not accept any expressions.

I have just tried it.

But if you use pure XML based JSF with tags, you can easily use <ui:param> as discussed here. I use JSF in JSP and for me there is no help (<c:set> is mostly useless).

-1
votes

Can I just do this in Home.xhtml before I ui:include stockQuoteFragment.xhtml into it:

<c:set var="#{StockQuoteService.stockID}" value="#homeBackingBean.userFavoriteStockID"/>

will that work?