Those calls (and other components you may create) are wrong:
       HtmlPanelGrid grid = new HtmlPanelGrid ();
       HtmlCommandLink link = new HtmlCommandLink ();

To create component, use the 
FacesContext.getApplication().createComponent(componentType) call.

example:

import javax.faces.context.FacesContext;
import javax.faces.component.html.HtmlCommandLink;  
....
HtmlCommandLink commandLink =
(HtmlCommandLink)context.getApplication().createComponent(HtmlCommandLink.COMPONENT_TYPE);

koshi a écrit :
> Hi, first of all, thanks for all your post and ideas, i'm grateful for your
> support.
>
> i decided to solve my problem this way
>
> in the view: 
>   <h:panelGrid binding="#{managedBean.panelGrid}" /> 
>
> the managed bean:
> public HtmlPanelGrid getPanelGrid ()
> {
>       HtmlPanelGrid grid = new HtmlPanelGrid ();
>       ....
>
>       for (Actions action : actions) {
>       
>             if (action.getType () == ActionTypes.COMMAND_LINK) {
>                     HtmlCommandLink link = new HtmlCommandLink ();
>                     link.setId (action.getId ());
>                     link.setTitle (action.getTitle ());
>  
>                     HtmlOutputText text = new HtmlOutputText ();
>                     text.setValue (MessagesUtil.getMessage ("actions",
> action.getTitle (), null));
>         
>                     link.getChildren ().add (text);
>         
>                     MethodBinding method = FacesContext.getCurrentInstance
> ().getApplication ().
>                                     createMethodBinding (action.getValue (),
> null);
>                     link.setAction (method);
>                     grid.getChildren ().add (link);
>             }
>       }
>       return grid;
> }
>
> but the commandLink doesn't work, and i have no idea of what is happening.
>
> if i put a commandLink into the panelGrid manually, then the commandLink
> works fine.
>
> <h:panelGrid id="id" binding="#{managedBean.panelGrid}">
>        <h:commandLink id = "asd"  action="#{managedBean.action}">
>             <h:outputText value="action name" />
>        </h:commandLink>
> </h:panelGrid>
>
> Thanks
>   

Reply via email to