Forums Register Login

t:inputText id="test", how to get its value?

+Pie Number of slices to send: Send
in a selection criteria screen, there is a <t:inputText id="test"/> component, how to get its value?
+Pie Number of slices to send: Send
Peter getting the value of the specified component is easy. Make use of the value attribute. Are you comfortable with the concept of backing bean ? If yes then it will come to you in a minute.

I will try to give a small example for you here.

In the page the code will be



In backing Bean make a property and write its getter and setters as well.


Hope this will solve your problem.
+Pie Number of slices to send: Send
You don't "get" a JSF value. A JSF page is a View, and it references a Model. Your tag misses a critical attribute:

<t:inputText id="test" value="#{bean.property}"/>

This will cause the JSF Controller to inject the value of the inputText field into the property named "property" of the bean which has been named "bean" in your jsf faces-config.xml file.
+Pie Number of slices to send: Send
Oh, theat means all h:inputText must have a backing bean,otherwise we have no method to get the value?
+Pie Number of slices to send: Send
JSF is a framework and backing bean is a part of it. You cannot test the functionality of most of the componenet without using backing bean. Please go through some good examples to understand it in a better way.
+Pie Number of slices to send: Send
 

Originally posted by peter tong:
Oh, theat means all h:inputText must have a backing bean,otherwise we have no method to get the value?



Before you get into details, you really need to get an understanding of what JSF is all about. I think, actually, that you're looking at it as though the JSF pages are where the program logic is based, and that isn't so. In fact, one of the bits of advice I provide more than almost any other in this forum is that JSF pages should have as little logic on them as possible. None at all, if you can.

JSF is about as complete an implementation of the classic Model/View/Controller paradigm as you can manage when HTTP is your underlying transport mechanism. It's also very much based on the concept of Inversion of Control (IoC), where you don't "get" things, they're injected into your code.

I had to learn to think of web application structure a lot differently when I started working with JSF. So will you.
+Pie Number of slices to send: Send
Just been looking at JSF quickly and have a quick question to ask. I've put it here because this thread seems to be along the same lines...

I found this quick sample 2 page app called JSFKickStart.

Basically has 2 JSPs and a Bean, with the following smippets



Now my question is, how does JSP1 or JSP2 know to use the Getter or Setter?

Usually you'd expect to see something like



But as if by magic JSF seems to know which to use, what's the 'background' logic going on here?

PS: Early opinion is that JSF look very much the thing for me, but it will be very hard to drag me away from 5 years or so of classic JSP/Servlet/Bean coding!

---

Just like to add another observation to this question...

Pu a couple of simple Sys.outs in the Bean to see when, what is called and noticed this:



It 'gets' the method getPersonName twice!
It gets the method getPersonName, then gets the method setPersonName, then gets the method getPersonName again!

That seems an extra 'call', why is this?
[ November 20, 2008: Message edited by: Keith Seller ]
This tiny ad will self destruct in five seconds.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 13688 times.
Similar Threads
MyFaces-Date/TimeZone Issue?
Page not getting submitted if my text box is not part of backing bean...
how to acces backingBean from popup
How to add a button to the first row of a dataTable
JSF Validation - How to identify the component which calls the validate method in the nethod itself
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:28:27.