You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Abushammala, Hani (EXTERN: FTP)" <ex...@volkswagen.de> on 2009/10/15 11:29:23 UTC

[Tobago] dynamic panels in tc:sheet

Hi all.

I would like to create a tc:sheet as follows:

In want add a panel to a Colmun, which has many command elements for
each row in the sheet.
I have written a method to create a panel for the row object of the
sheet, but 
i need help to bind the method with jstl or java to the panel. 



JSP:

   <tc:sheet value="#{controller.objects}" id="objectSheet" var="object"
>
       <tc:column id="col1" sortable="false">
          <tc:out value="#{object.attribut}" id="t_out" />
       </tc:column>
	<tc:column id="col2" sortable="false">
          <tc:panel binding="#{.....}"  id="t_panel" />
       </tc:column>
   </tc:sheet>



Controller:

 public UIComponent createPanel(Object obj) {

        FacesContext facesContext = FacesContext.getCurrentInstance();

        UIPanel panel = (UIPanel)
ComponentUtil.createComponent(facesContext,
 
UIPanel.COMPONENT_TYPE,
 
TobagoConstants.RENDERER_TYPE_PANEL,
 
"img_panel");
        for (int i = 0; i < ob.getImgObjects.size(); i++) {
            ImgObj img = ob.getImgObjects.get(i);
            UILinkCommand linkCommand = (UILinkCommand)
ComponentUtil.createComponent(facesContext,
 
UILinkCommand.COMPONENT_TYPE,
 
TobagoConstants.RENDERER_TYPE_LINK,
 
"link" + i);
            ComponentUtil.setStringProperty(linkCommand,
TobagoConstants.ATTR_IMAGE, img.getIconUrl());
            panel.getChildren().add(linkCommand);
        }
        
        return panel;
    }


Any suggestions?


Regards

Hani

AW: [Tobago] dynamic panels in tc:sheet

Posted by "Abushammala, Hani (EXTERN: FTP)" <ex...@volkswagen.de>.
Hi Volker,

I don`t get it.

Please look at the picture in the attachment.
The List of the figures for each row object is dynamic and different.
Is that possible in tobago?  How can i programe it?

Thank You


Regards,
Hani

-----Ursprüngliche Nachricht-----
Von: weber.volker@googlemail.com [mailto:weber.volker@googlemail.com] Im Auftrag von Volker Weber
Gesendet: Samstag, 17. Oktober 2009 22:53
An: MyFaces Discussion
Betreff: Re: [Tobago] dynamic panels in tc:sheet

Hi Hani,

you can't have different UIComponents in the rows.

There is only one set of components which is rendered multiple times
for the rows, if you need different row contents you need to add all
components and hide some of them via rendered attribute.


Regards,
    Volker



2009/10/16 Abushammala, Hani (EXTERN: FTP)
<ex...@volkswagen.de>:
> Thank you Volker,
>
>
>
> The updating of the panel must be dependent on the row object of the sheet,
> that means the content of the panel for each row is different.
> How can i tell the set-method for the panel the row object.
>
> How can i reach that?
>
> Regards,
>
> Hani
>
> -----Ursprüngliche Nachricht-----
> Von: weber.volker@googlemail.com [mailto:weber.volker@googlemail.com] Im Auftrag von Volker Weber
> Gesendet: Freitag, 16. Oktober 2009 09:38
> An: MyFaces Discussion
> Betreff: Re: [Tobago] dynamic panels in tc:sheet
>
> Hi Hani,
>
> 2009/10/15 Abushammala, Hani (EXTERN: FTP)
> <ex...@volkswagen.de>:
>> Hi all.
>>
>> I would like to create a tc:sheet as follows:
>>
>> In want add a panel to a Colmun, which has many command elements for each
>> row in the sheet.
>> I have written a method to create a panel for the row object of the sheet,
>> but
>> i need help to bind the method with jstl or java to the panel.
>>
>> JSP:
>>
>>    <tc:sheet value="#{controller.objects}" id="objectSheet" var="object" >
>>        <tc:column id="col1" sortable="false">
>>           <tc:out value="#{object.attribut}" id="t_out" />
>>        </tc:column>
>>         <tc:column id="col2" sortable="false">
>>           <tc:panel binding="#{.....}"  id="t_panel" />
>
> <tc:panel binding="#{controller.cmdPanel}"  id="t_panel" />
>
>>        </tc:column>
>>    </tc:sheet>
>>
>> Controller:
>>
>
> public UIComponent getCmdPanel() {
>  // important return null here and create content in setCmdPanel()
>  return null;
> }
>
>
> // create the content of dynamic panel in the bindinsg setter
> // let jsf create the panel and just add content
> public void setCmdPanel(UIComponent panel) {
>
>    // skip if this panel has already children
>    if (!panel.getChildren().isEmpty()) {
>      return;
>    }
>
>    FacesContext facesContext = FacesContext.getCurrentInstance();
>
>        for (int i = 0; i < ob.getImgObjects.size(); i++) {
>            ImgObj img = ob.getImgObjects.get(i);
>            UILinkCommand linkCommand = (UILinkCommand)
> ComponentUtil.createComponent(facesContext,
>
>               UILinkCommand.COMPONENT_TYPE,
>
>               TobagoConstants.RENDERER_TYPE_LINK,
>
>               "link" + i);
>            ComponentUtil.setStringProperty(linkCommand,
> TobagoConstants.ATTR_IMAGE, img.getIconUrl());
>            panel.getChildren().add(linkCommand);
>        }
>
>    }
>
>
>
> In jsf the getter of the binding of a component is called once at
> component creation at the first rendering of the view.
> The setter is called if the getter returns null (with a UIComponent
> instance created by the framework) and at every restoreView.
>
>
> Your sould never store the component given by the setter somewhere, at
> least not longer than request scope.
>
>
> Hope this helps,
>
> Regards,
>    Volker
>
>
>>
>> Any suggestions?
>>
>> Regards
>>
>> Hani
>
>
>
> --
> inexso - information exchange solutions GmbH
> Bismarckstraße 13      | 26122 Oldenburg
> Tel.: +49 441 4082 356 |
> FAX:  +49 441 4082 355 | www.inexso.de
>



-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

Re: [Tobago] dynamic panels in tc:sheet

Posted by Volker Weber <v....@inexso.de>.
Hi Hani,

you can't have different UIComponents in the rows.

There is only one set of components which is rendered multiple times
for the rows, if you need different row contents you need to add all
components and hide some of them via rendered attribute.


Regards,
    Volker



2009/10/16 Abushammala, Hani (EXTERN: FTP)
<ex...@volkswagen.de>:
> Thank you Volker,
>
>
>
> The updating of the panel must be dependent on the row object of the sheet,
> that means the content of the panel for each row is different.
> How can i tell the set-method for the panel the row object.
>
> How can i reach that?
>
> Regards,
>
> Hani
>
> -----Ursprüngliche Nachricht-----
> Von: weber.volker@googlemail.com [mailto:weber.volker@googlemail.com] Im Auftrag von Volker Weber
> Gesendet: Freitag, 16. Oktober 2009 09:38
> An: MyFaces Discussion
> Betreff: Re: [Tobago] dynamic panels in tc:sheet
>
> Hi Hani,
>
> 2009/10/15 Abushammala, Hani (EXTERN: FTP)
> <ex...@volkswagen.de>:
>> Hi all.
>>
>> I would like to create a tc:sheet as follows:
>>
>> In want add a panel to a Colmun, which has many command elements for each
>> row in the sheet.
>> I have written a method to create a panel for the row object of the sheet,
>> but
>> i need help to bind the method with jstl or java to the panel.
>>
>> JSP:
>>
>>    <tc:sheet value="#{controller.objects}" id="objectSheet" var="object" >
>>        <tc:column id="col1" sortable="false">
>>           <tc:out value="#{object.attribut}" id="t_out" />
>>        </tc:column>
>>         <tc:column id="col2" sortable="false">
>>           <tc:panel binding="#{.....}"  id="t_panel" />
>
> <tc:panel binding="#{controller.cmdPanel}"  id="t_panel" />
>
>>        </tc:column>
>>    </tc:sheet>
>>
>> Controller:
>>
>
> public UIComponent getCmdPanel() {
>  // important return null here and create content in setCmdPanel()
>  return null;
> }
>
>
> // create the content of dynamic panel in the bindinsg setter
> // let jsf create the panel and just add content
> public void setCmdPanel(UIComponent panel) {
>
>    // skip if this panel has already children
>    if (!panel.getChildren().isEmpty()) {
>      return;
>    }
>
>    FacesContext facesContext = FacesContext.getCurrentInstance();
>
>        for (int i = 0; i < ob.getImgObjects.size(); i++) {
>            ImgObj img = ob.getImgObjects.get(i);
>            UILinkCommand linkCommand = (UILinkCommand)
> ComponentUtil.createComponent(facesContext,
>
>               UILinkCommand.COMPONENT_TYPE,
>
>               TobagoConstants.RENDERER_TYPE_LINK,
>
>               "link" + i);
>            ComponentUtil.setStringProperty(linkCommand,
> TobagoConstants.ATTR_IMAGE, img.getIconUrl());
>            panel.getChildren().add(linkCommand);
>        }
>
>    }
>
>
>
> In jsf the getter of the binding of a component is called once at
> component creation at the first rendering of the view.
> The setter is called if the getter returns null (with a UIComponent
> instance created by the framework) and at every restoreView.
>
>
> Your sould never store the component given by the setter somewhere, at
> least not longer than request scope.
>
>
> Hope this helps,
>
> Regards,
>    Volker
>
>
>>
>> Any suggestions?
>>
>> Regards
>>
>> Hani
>
>
>
> --
> inexso - information exchange solutions GmbH
> Bismarckstraße 13      | 26122 Oldenburg
> Tel.: +49 441 4082 356 |
> FAX:  +49 441 4082 355 | www.inexso.de
>



-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

AW: [Tobago] dynamic panels in tc:sheet

Posted by "Abushammala, Hani (EXTERN: FTP)" <ex...@volkswagen.de>.
Thank you Volker,



The updating of the panel must be dependent on the row object of the sheet, 
that means the content of the panel for each row is different.
How can i tell the set-method for the panel the row object.

How can i reach that?

Regards,

Hani

-----Ursprüngliche Nachricht-----
Von: weber.volker@googlemail.com [mailto:weber.volker@googlemail.com] Im Auftrag von Volker Weber
Gesendet: Freitag, 16. Oktober 2009 09:38
An: MyFaces Discussion
Betreff: Re: [Tobago] dynamic panels in tc:sheet

Hi Hani,

2009/10/15 Abushammala, Hani (EXTERN: FTP)
<ex...@volkswagen.de>:
> Hi all.
>
> I would like to create a tc:sheet as follows:
>
> In want add a panel to a Colmun, which has many command elements for each
> row in the sheet.
> I have written a method to create a panel for the row object of the sheet,
> but
> i need help to bind the method with jstl or java to the panel.
>
> JSP:
>
>    <tc:sheet value="#{controller.objects}" id="objectSheet" var="object" >
>        <tc:column id="col1" sortable="false">
>           <tc:out value="#{object.attribut}" id="t_out" />
>        </tc:column>
>         <tc:column id="col2" sortable="false">
>           <tc:panel binding="#{.....}"  id="t_panel" />

<tc:panel binding="#{controller.cmdPanel}"  id="t_panel" />

>        </tc:column>
>    </tc:sheet>
>
> Controller:
>

public UIComponent getCmdPanel() {
  // important return null here and create content in setCmdPanel()
  return null;
}


// create the content of dynamic panel in the bindinsg setter
// let jsf create the panel and just add content
public void setCmdPanel(UIComponent panel) {

    // skip if this panel has already children
    if (!panel.getChildren().isEmpty()) {
      return;
    }

    FacesContext facesContext = FacesContext.getCurrentInstance();

        for (int i = 0; i < ob.getImgObjects.size(); i++) {
            ImgObj img = ob.getImgObjects.get(i);
            UILinkCommand linkCommand = (UILinkCommand)
ComponentUtil.createComponent(facesContext,

               UILinkCommand.COMPONENT_TYPE,

               TobagoConstants.RENDERER_TYPE_LINK,

               "link" + i);
            ComponentUtil.setStringProperty(linkCommand,
TobagoConstants.ATTR_IMAGE, img.getIconUrl());
            panel.getChildren().add(linkCommand);
        }

    }



In jsf the getter of the binding of a component is called once at
component creation at the first rendering of the view.
The setter is called if the getter returns null (with a UIComponent
instance created by the framework) and at every restoreView.


Your sould never store the component given by the setter somewhere, at
least not longer than request scope.


Hope this helps,

Regards,
    Volker


>
> Any suggestions?
>
> Regards
>
> Hani



-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

Re: [Tobago] dynamic panels in tc:sheet

Posted by Volker Weber <v....@inexso.de>.
Hi Hani,

2009/10/15 Abushammala, Hani (EXTERN: FTP)
<ex...@volkswagen.de>:
> Hi all.
>
> I would like to create a tc:sheet as follows:
>
> In want add a panel to a Colmun, which has many command elements for each
> row in the sheet.
> I have written a method to create a panel for the row object of the sheet,
> but
> i need help to bind the method with jstl or java to the panel.
>
> JSP:
>
>    <tc:sheet value="#{controller.objects}" id="objectSheet" var="object" >
>        <tc:column id="col1" sortable="false">
>           <tc:out value="#{object.attribut}" id="t_out" />
>        </tc:column>
>         <tc:column id="col2" sortable="false">
>           <tc:panel binding="#{.....}"  id="t_panel" />

<tc:panel binding="#{controller.cmdPanel}"  id="t_panel" />

>        </tc:column>
>    </tc:sheet>
>
> Controller:
>

public UIComponent getCmdPanel() {
  // important return null here and create content in setCmdPanel()
  return null;
}


// create the content of dynamic panel in the bindinsg setter
// let jsf create the panel and just add content
public void setCmdPanel(UIComponent panel) {

    // skip if this panel has already children
    if (!panel.getChildren().isEmpty()) {
      return;
    }

    FacesContext facesContext = FacesContext.getCurrentInstance();

        for (int i = 0; i < ob.getImgObjects.size(); i++) {
            ImgObj img = ob.getImgObjects.get(i);
            UILinkCommand linkCommand = (UILinkCommand)
ComponentUtil.createComponent(facesContext,

               UILinkCommand.COMPONENT_TYPE,

               TobagoConstants.RENDERER_TYPE_LINK,

               "link" + i);
            ComponentUtil.setStringProperty(linkCommand,
TobagoConstants.ATTR_IMAGE, img.getIconUrl());
            panel.getChildren().add(linkCommand);
        }

    }



In jsf the getter of the binding of a component is called once at
component creation at the first rendering of the view.
The setter is called if the getter returns null (with a UIComponent
instance created by the framework) and at every restoreView.


Your sould never store the component given by the setter somewhere, at
least not longer than request scope.


Hope this helps,

Regards,
    Volker


>
> Any suggestions?
>
> Regards
>
> Hani



-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de