Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Every one of us has filled out an online application at least once. You might not be aware that other than details you fill yourself, some hidden data also gets passed through. These can include your machine's local time, IMEI numbers, browser version etc. All these functionalities are achieved through the use of JSF's inputHidden tag. So what are you waiting for? Let's get into the working of this tag.
inputHidden Tag
It is similar to the 'hidden' element in HTML. It allows you to pass confidential information while submitting forms. Similar to HTML elements, you can provide it with an ID, class name, value, required fields etc. The class name can be targeted using CSS.
Syntax:
<h:inputHidden value="I love Coding Ninjas" />
Attributes
Attribute
Description
id
Defines ID for the tag.
value
Holds the current value of the tag.
required
Specifies whether the user mandatorily needs to submit data for this tag or not.
class
CSS classname for this element.
binding
Reference to the component that can be used in a backing bean.
style
Used to specify inline styling
Sample Program
A JSF example to render <h:inputHidden/> tag, and access hidden value using JavaScript.
User-managed bean code
package com.coding_ninjas.form;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import java.io.Serializable;
@ManagedBean(name="ninja")
@SessionScoped
public class UserBean implements Serializable {
String answer = "I'm Hidden value!";
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
}
XHTML Page Code
If the button is clicked, print the hidden value using JS.
JSF is a UI development framework similar to React. It is based on components as its building blocks. It connects parts to data sources, directly improving security and efficiency.
What is a UI?
It is the space of user and machine interaction. It forms an integral part of user experience (UX), consisting of visual and functional design. UI aims to make it easier for users to interact with the product.
What is a tag?
A tag is a syntactical way of implementing program logic. These tags are like keywords which define how to display elements on the web browser. For example <html>, <img> etc.
What is localhost?
Localhost defines the machine's address, also known as the loopback address. While setting up a local test environment, localhost address's come in handy. For example, if you would ping localhost, it will reflect 127.0.0.1.
What is the prerequisite to running the JSF program?
Java Runtime Environment, JDK, Maven and Apache tomcat facilitate the running of JSF applications.
Conclusion
Finally, you have made it to the end of this article. Congratulations!! In this blog, you learnt about the inputHidden tag in JSF. You went through the tag, its attributes and a sample program.
After reading about the inputHidden tag, are you not feeling excited to read more articles on the topic of JSF? Don't worry; Coding Ninjas has you covered. To learn, see the JSF.