This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating HtmlCommandButton and HtmlForm in a custom tag

 
Nick Seward
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following bit of JSF code:



The excluded parts are scriplets that populate a <select> html menu and write out the HTML for the menu. I am taking a different approach and creating a custom tag to clean up the scriplets. I have the tag created and JSF registers and displays the tag fine. The problem lies in creating the form and commandButton in the custom tag. It seems to output everything fine but when I click on the button the class.method is not called. Below is my code from the custom tag that creates the form and button:




The class used for the action listener is a session level managed bean in JSF. The method is called fine in the JSF code from before I started creating this custom tag, so I know the bean works. My question is, what is going on? What am I forgetting to set or call? Creating custom JSF tags is a bit new for me and I am used to creating custom JSP tags. Either way I am trying to figure this out and any help or suggested links for me to read are appreciated.

Lastly, this is all in MyFaces 1.1.4 on Apache Tomcat.
-Nick
[ March 11, 2008: Message edited by: Nick Seward ]
 
Nick Seward
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to figure out most of my problem. I'll post it here in case any one else tries this. First, I wasn't aware that what I am doing is called a composite component pattern.



I still have an issue with setting the action for the HtmlCommandButton. In the old JSF code I have this

<h:commandButton id="gobtn" action="go_toc" actionListener="#{class.method}" value="Go" styleClass="frmField" onclickity="top.UserLocker.on();" />

The action attribute is set to "go_toc" which is a string for JSF to use when navigating to another page after the button is clicked. Setting this in my composite tag is not easy to figure out. Does anyone know how to do that?
There is a setAction(MethodBinding mb) method for HTmlCommandButton but it accepts a method binding and I already have that set by setting the actionListener attribute in my composite tag code. So I don't think setAction is the way to go.

Thanks,
Nick
 
Nick Seward
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I am guessing nobody has any ideas? I hope this is not a stupid question with the answer staring me right in the face.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic