java - Dynamic call to message bundles? -
i have simple jsf 2.0 project.
i have index.xhtml file show me picture of mount rushmore. on page, can click on picture , want go "president.xhtml" - no problem in that. simple action=""...
my problem message bundle file (messages.properties) set static keys , values, ex.:
jeffersonpagetitle=thomas jefferson rooseveltpagetitle=theodore roosevelt lincolnpagetitle=abraham lincoln washingtonpagetitle=george washington
and in "president.xhtml" file, want show these titles depending on clicked on.
<h:form> <span class="presidentpagetitle">#{msgs['rushmore.president'],pagetitle}</span> <br /> <h:graphicimage library="images" name="jefferson.jpg" styleclass="leftimage" /> <span class="presidentdiscussion">#{msgs.washingtondiscussion}</span> <br /> <h:commandlink action="index" styleclass="backlink">${msgs.indexlinktext}</h:commandlink> </h:form>
second line in code above problem - don't know how refer get-method in java-code. code here:
@managedbean // or @named @requestscoped public class rushmore { private string outcome = null; private rectangle washingtonrect = new rectangle(70, 30, 40, 40); private rectangle jeffersonrect = new rectangle(115, 45, 40, 40); private rectangle rooseveltrect = new rectangle(135, 65, 40, 40); private rectangle lincolnrect = new rectangle(175, 62, 40, 40); public rushmore() {} public void handlemouseclick(actionevent e) { facescontext context = facescontext.getcurrentinstance(); string clientid = e.getcomponent().getclientid(context); map<string, string> requestparams = context.getexternalcontext().getrequestparametermap(); int x = new integer((string) requestparams.get(clientid + ".x")).intvalue(); int y = new integer((string) requestparams.get(clientid + ".y")).intvalue(); outcome = null; if (washingtonrect.contains(new point(x, y))) { outcome = "washington"; } if (jeffersonrect.contains(new point(x, y))) { outcome = "jefferson"; } if (rooseveltrect.contains(new point(x, y))) { outcome = "roosevelt"; } if (lincolnrect.contains(new point(x, y))) { outcome = "lincoln"; } system.out.println(requestparams.keyset()); } public string getpresident() { return outcome; } public string navigate() { if(outcome != null) { return "president"; } else return null; } }
it's getpresident method i'm trying reach in president.xhtml file...
any appreciated :)
use c:set
.
<html xmlns:c="http://java.sun.com/jsp/jstl" ...> ... <c:set var="pagetitle" value="#{rushmore.president}pagetitle" /> <span class="presidentpagetitle">#{msgs[pagetitle]}</span>
Comments
Post a Comment