2

in JSF, I were using: rich:popupPanel to display some information that calculated by Javascript. Normally I often use h:outputText to diplay value but I don't know how to diplay javascript value on HTML. Can I display it with h:outputText ? Thanks

1 Answer 1

2

Ignore JSF and just use the normal JavaScript/HTML DOM means. JSF is for them merely a HTML code generator. JS has no knowledge about the JSF source code, all it has access to is its generated HTML source code (exactly the one as you see by rightclick and View Source in the webbrowser).

Imagine that JSF has generated the following HTML, e.g. by <h:outputText id="foo"> or just hardcoding it as-is (you can just write plain HTML in a JSF page, do you know?):

<span id="foo"></span>

Then you can use JS as follows to fill its node value with a JS variable:

var foo = "some value";
document.getElementById("foo").innerHTML = foo;

This will ultimately appear dynamically as follows in the HTML DOM which get also visually reflected in UI:

<span id="foo">some value</span>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.