*
The moose likes JSF and the fly likes Creating HtmlCommandButton and HtmlForm in a custom tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Creating HtmlCommandButton and HtmlForm in a custom tag" Watch "Creating HtmlCommandButton and HtmlForm in a custom tag" New topic
Author

Creating HtmlCommandButton and HtmlForm in a custom tag

Nick Seward
Greenhorn

Joined: Mar 11, 2008
Posts: 3
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

Joined: Mar 11, 2008
Posts: 3
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

Joined: Mar 11, 2008
Posts: 3
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating HtmlCommandButton and HtmlForm in a custom tag
 
Similar Threads
Form Level Error Messages In JSF
Dynamic UI generation problem while opening popup
Setting ID attribute in backing bean
HtmlInputText
Conversion Error setting value