Hello,
I'm coming from a PHP background, and I've run into a wall with JSF. I
know how I'd get around it with PHP or ASP.NET, but for JSF I'm
stumped.
Here's the scenario:
I'm making a message board. It has multiple forum each of which has
many topics, each of which has many posts. Very standard thing here. I
am implementing the page which allows a user to create a new topic.
The URI is of the form "createTopic.jsf?forumId=<n>" where <n> is an
integer corresponding to the forum's primary key in the database. I
have a backing bean mapped in faces-config to "CreateTopicBean", and
it is request scoped. Now, when the user submits the form to create a
topic, what is the best way to let the bean know which forum this
topic should be created under? I tried having a managed property like
this:
<managed-bean>
<managed-bean-name>CreateTopicBean</managed-bean-name>
<managed-bean-class>
com.wepwnsnails.faces.managedbean.CreateTopicBean
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>forumId</property-name>
<value>#{param.forumId}</value>
</managed-property>
</managed-bean>
but when the "action" attribute of the html <form> element rendered by
JSF is simply "createTopic.jsf", so an EL exception is thrown when JSF
fails to set the managed property.
I've also tried adding a <h:inputHidden> tag set to the forumId on the
backing bean in a variety of ways, but they leave much to be desired
as far as cleanliness.
I'm sure that this is an issue every newbie JSF developer has
scratched his head over; so what's the best way to go about this? I've
had a hard time finding anything in Google, mostly because I don't
know how to tersely phrase the problem for a seach query.
Thanks a lot,
benjamin van der veen