@GET
 @Produces(MediaType.APPLICATION_XML)
 @Path("all")
 public Customers getCustomers() {
   List<Customer> customers = new ArrayList<Customer>();
   customers.addAll(testBean.getCustomerMap().values());
   Customers allCustomers = new Customers();
   allCustomers.setCustomer(customers);
   return allCustomers;
 }
示例#2
0
 @Override
 public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
   if (object == null) {
     return null;
   }
   if (object instanceof Customers) {
     Customers o = (Customers) object;
     return getStringKey(o.getCustomerId());
   } else {
     Logger.getLogger(this.getClass().getName())
         .log(
             Level.SEVERE,
             "object {0} is of type {1}; expected type: {2}",
             new Object[] {object, object.getClass().getName(), Customers.class.getName()});
     return null;
   }
 }
  public CustomerEdit(
      String title,
      boolean visible,
      boolean undecorate,
      boolean resizeable,
      Dimension dimension,
      final String id)
      throws SQLException, ClassNotFoundException {
    super(title, visible, undecorate, resizeable, dimension);
    setUndecorated(true);
    RemovablePanel contenPane = new RemovablePanel(this);
    Color BackGround = Color.getHSBColor(20, 12, 21);
    contenPane.setBackground(BackGround);
    this.setContentPane(contenPane);
    setLayout(null);
    CustomLabel titleLabel =
        new CustomLabel(
            "Edit customer",
            Color.BLACK,
            Configure.DEFAULT_RIGHT_PANEL_COLOR,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 24),
            new Point(20, 17),
            new Dimension(360, 40),
            true,
            SwingConstants.LEFT,
            SwingConstants.CENTER,
            contenPane);

    Dimension dim = dimension;
    final HintTextField name =
        new HintTextField(
            " Name",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 70),
            new Dimension(dim.width - 40, 30),
            contenPane,
            false);
    final HintTextField type =
        new HintTextField(
            " Type",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 110),
            new Dimension(dim.width - 40, 30),
            contenPane,
            false);
    final HintTextField relationShip =
        new HintTextField(
            " Relationship",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 150),
            new Dimension(dim.width - 40, 30),
            contenPane,
            false);
    final HintTextField phone =
        new HintTextField(
            " Phone",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 190),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);
    final HintTextField fax =
        new HintTextField(
            " Fax",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(205, 190),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);
    final HintTextField email =
        new HintTextField(
            " Email",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 230),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);
    final HintTextField address =
        new HintTextField(
            " Address",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(205, 230),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);

    final CustomButton ok =
        new CustomButton(
            "Save",
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 14),
            false,
            false,
            Color.GRAY,
            true,
            new Point(20, 280),
            new Dimension((dim.width - 50) / 2, 30),
            contenPane);

    Customers custemp = Customers.viewCustomer(id);

    name.setText(custemp.getCustomerName());
    type.setText(custemp.getCustomerType());
    relationShip.setText(custemp.getCustomerRelationship());
    phone.setText(custemp.getCustomerPhone());
    fax.setText(custemp.getCustomerFax());
    email.setText(custemp.getCustomerEmail());
    address.setText(custemp.getCustomerAddress());
    System.out.println(
        name.getText().toString() + " " + phone.getText().toString() + "kfsjdhfdskjfh");
    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {

            String namex = name.getText().toString();
            String typex = type.getText().toString();
            String relx = relationShip.getText().toString();
            String phonex = phone.getText().toString();
            String faxx = fax.getText().toString();
            String emailx = email.getText().toString();
            String addressx = address.getText().toString();
            try {
              Customers.editCustomer(namex, typex, phonex, faxx, emailx, addressx, relx, id);
            } catch (SQLException ex) {
              Logger.getLogger(CustomerEdit.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(CustomerEdit.class.getName()).log(Level.SEVERE, null, ex);
            }

            CustomerEdit.this.dispose();
          }
        });

    final CustomButton cancel =
        new CustomButton(
            "Cancel",
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 14),
            false,
            false,
            Color.LIGHT_GRAY,
            true,
            new Point(20 + 10 + (dim.width - 50) / 2, 280),
            new Dimension((dim.width - 50) / 2, 30),
            contenPane);

    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            CustomerEdit.this.dispose();
          }
        });
  }