Thanks a lot,

The mailing list does not seem to exist. Could not post to "[EMAIL PROTECTED]"

Stefan



 

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Matthias 
Wessendorf
Gesendet: Mittwoch, 13. Dezember 2006 10:17
An: MyFaces Discussion
Betreff: Re: Dailog and Trinidad table

I have a demo on some trinidad features, one of the examples is exactly that.
I can hand you offline if the following is not enough. In [1] there are also 
useful informations on the dialog

-Matthias

[1] http://incubator.apache.org/adffaces/devguide/index.html

code-------------------------------------------

customers.xhtml (the table):
<tr:document
   xmlns:ui="http://java.sun.com/jsf/facelets";
   xmlns:h="http://java.sun.com/jsf/html";
   xmlns:f="http://java.sun.com/jsf/core";
   xmlns:tr="http://myfaces.apache.org/trinidad";
   title="Dialog Framework">

  <tr:form>
     <tr:table id="data" border="2" binding="#{cm.table}" var="customer">
   <tr:column>
     <tr:outputText value="#{customer.companyName}" />
   </tr:column>
   <tr:column>
     <tr:outputText value="#{customer.contactPerson}" />
   </tr:column>
   <tr:column>
     <tr:outputText value="#{customer.phone}" />
   </tr:column>
   <tr:column>
      <tr:commandLink text="edit" action="dialog:edit"
           returnListener="#{cm.handleReturn}" partialSubmit="true"
           useWindow="true">
        <tr:setActionListener from="#{customer}"
to="#{pageFlowScope.currentCustomer}" />
      </tr:commandLink>
   </tr:column>

   </tr:table>
  </tr:form>
</tr:document>


edit1.xhtml (first page in wizard):
<tr:document
   xmlns:ui="http://java.sun.com/jsf/facelets";
   xmlns:h="http://java.sun.com/jsf/html";
   xmlns:f="http://java.sun.com/jsf/core";
   xmlns:tr="http://myfaces.apache.org/trinidad";
   title="Dialog Framework">

         <tr:form>
           <tr:messages/>
           <tr:panelHeader text="Enter your username and your password">
            <tr:panelFormLayout>
        <tr:inputText label="Company name" id="input1"
value="#{processScope.currentCustomer.companyName}" />
        <tr:inputText label="contact person" id="input2"
value="#{processScope.currentCustomer.contactPerson}" />
            </tr:panelFormLayout>
           </tr:panelHeader>
     <tr:commandButton id="button1" text="next" action="second" />
        </tr:form>

</tr:document>


edit2.xhtml (second page in wizard):
<tr:document
   xmlns:ui="http://java.sun.com/jsf/facelets";
   xmlns:h="http://java.sun.com/jsf/html";
   xmlns:f="http://java.sun.com/jsf/core";
   xmlns:tr="http://myfaces.apache.org/trinidad";
   title="Dialog Framework">
         <tr:form>
           <tr:messages/>
           <tr:panelHeader text="Enter your name and your favorite color">
            <tr:panelFormLayout>
        <tr:inputText label="Phone" id="input1"
value="#{processScope.currentCustomer.phone}" />
            </tr:panelFormLayout>
           </tr:panelHeader>
           <tr:commandButton text="Save" action="#{cm.save}">
     </tr:commandButton>
        </tr:form>
</tr:document>


and my customer manager bean (the #{cm} bb ):
package net.wessendorf.bob.faces.users;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.myfaces.trinidad.component.UIXTable;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.event.ReturnEvent;

public class CustomerManager
{

  private List customers;

  public void handleReturn(ReturnEvent event)
  {
    this.table.setValue(customers);
    RequestContext afContext = RequestContext.getCurrentInstance();
    afContext.addPartialTarget(table);
  }

  public String save()
  {
    Customer cm =
(Customer)RequestContext.getCurrentInstance().getPageFlowScope().get("currentCustomer");
    RequestContext.getCurrentInstance().returnFromDialog(cm, null);
    RequestContext.getCurrentInstance().getPageFlowScope().clear();
    return null;
  }


  public Customer getUserById(int id)
  {
    Customer ret = null;

    for (Iterator iter = customers.iterator(); iter.hasNext();)
    {
      Customer element = (Customer) iter.next();
      if(element.getId() == id)        ret=  element;
    }
    return ret;
  }

  private UIXTable table;

  public UIXTable getTable()
  {
    return table;
  }

  public void setTable(UIXTable table)
  {
    this.table = table;
    this.table.setValue(this.customers);
  }

  public CustomerManager()
  {
    this.customers = new ArrayList();

    Customer c1 = new Customer();
    c1.setId(1);
    c1.setCompanyName("A Inc");
    c1.setContactPerson("Mr Smith");
    c1.setPhone("510 43234 232");
    c1.setStreet("Bush Street");

    Customer c2 = new Customer();
    c2.setId(2);
    c2.setCompanyName("B Inc");
    c2.setContactPerson("Mr. Walterson");
    c2.setPhone("650 23433 873");
    c2.setStreet("Mc Nothing Bl. 12");

    Customer c3 = new Customer();
    c3.setId(3);
    c3.setCompanyName("C Corp.");
    c3.setContactPerson("Mrs. Johnson");
    c3.setPhone("650 23433 873");
    c3.setStreet("Spring Way 12");

    this.customers.add(c1);
    this.customers.add(c2);
    this.customers.add(c3);
  }

  public List getCustomers()
  {
    return customers;
  }

  public void setCustomers(List customers)
  {
    this.customers = customers;
  }
}






On 12/13/06, Meyer, Stefan <[EMAIL PROTECTED]> wrote:
> I am using a trinidad table and want to launch a dialog to edit the 
> detail of the entities represented by the columns. The launching 
> button is a commandButton with partialSubmit set to true. When 
> returning from the Dialog the column that displays the possibly 
> modified name of the edited entity is not updated althoug I set the 
> partialTriggers attribute. I tries to set the id of the button (and 
> the partialTriggers) to a constant and to a column dependent el expression. 
> It does not work.
> Is there a limitation because the columns are stamped components? How 
> do I trigger a partial update of the whole table upon returning?
>


--
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Reply via email to