Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    118
    Vote Rating
    0
    mtarantini is on a distinguished road

      0  

    Default MultiField and FormBinding / Form Validation

    MultiField and FormBinding / Form Validation


    Hi, I have a problem with the Multifield with FormBinding or FormValidation Validation.

    I have a FormPanel with 3 Fields : name, description and a Multifield which contains another name & description field.

    The model I try to bind is simple as well (see a the end of the Test Class), and I try to bind a property (description) from a ModelB contained in ModelA.

    1°) The problem is the binding works for the 2 first fields, but not on the MultiField.

    2°) When the fields from multifield are empty, and you click on the button, only the first field is valid, not both, is that a normal behavior ?

    I guess i'm doing something wrong, but what?

    Thanks again.

    Code:
    public class Test implements EntryPoint
    {
    
    	/**
    	 * This is the entry point method.
    	 */
    	public void onModuleLoad()
    	{
    		final FormPanel fp = new FormPanel();
    		fp.setSize(640, 200);
    
    		final TextField<String> nameField = new TextField<String>();
    		nameField.setName(ModelA.NAME);
    		nameField.setFieldLabel("Name");
    		nameField.setAllowBlank(false);
    
    		final TextField<String> descriptionField = new TextField<String>();
    		descriptionField.setName(ModelA.MODELB + "." + ModelB.DESCRIPTION);
    		descriptionField.setFieldLabel("Description");
    		descriptionField.setAllowBlank(false);
    
    		final TextField<String> nameFieldForMultiField = new TextField<String>();
    		nameFieldForMultiField.setName(ModelA.NAME);
    		nameFieldForMultiField.setAllowBlank(false);
    
    		final TextField<String> descriptionFieldForMultiField = new TextField<String>();
    		descriptionFieldForMultiField.setName(ModelA.MODELB + "." + ModelB.DESCRIPTION);
    		descriptionFieldForMultiField.setAllowBlank(false);
    
    		MultiField<String> multiField = new MultiField<String>("MultiField", nameFieldForMultiField, descriptionFieldForMultiField);
    		multiField.setResizeFields(true);
    		multiField.setSpacing(10);
    		
    		fp.add(nameField, new FormData("80%"));
    		fp.add(descriptionField, new FormData("80%"));
    		fp.add(multiField, new FormData("80%"));
    
    		Button validForm = new Button("Valid Form");
    		validForm.addSelectionListener(new SelectionListener<ButtonEvent>()
    		{
    
    			@Override
    			public void componentSelected(ButtonEvent ce)
    			{
    				fp.isValid();
    			}
    		});
    
    		fp.addButton(validForm);
    
    		final FormBinding binding = new FormBinding(fp, true);
    		ModelA modelA = new ModelA("Model A", new ModelB("Description B"));
    		binding.bind(modelA);
    
    		RootPanel.get().add(fp);
    
    	}
    
    	private class ModelA extends BaseModel
    	{
    
    		/** TODO Provide comment for serialVersionUID field */
    		private static final long serialVersionUID = 1L;
    		public static final String NAME = "name";
    		public static final String MODELB = "modelB";
    
    		public ModelA()
    		{
    		}
    
    		public ModelA(String name, ModelB description)
    		{
    			this();
    			set(NAME, name);
    			set(MODELB, description);
    		}
    	}
    
    	private class ModelB extends BaseModel
    	{
    
    		/** TODO Provide comment for serialVersionUID field */
    		private static final long serialVersionUID = 1L;
    		public static final String DESCRIPTION = "desc";
    
    		public ModelB()
    		{
    		}
    
    		public ModelB(String description)
    		{
    			this();
    			set(DESCRIPTION, description);
    		}
    	}
    }

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You cannot bind a multifield as you bind it. I will move this to the help forum.

    The multifield needs the name, not the two fields that are part of the multifield. You will also need to write some custom multifield binder.

    You can also add the two fields that are part of the multifield dynamically to the binding.

  3. #3
    Sencha User
    Join Date
    May 2009
    Posts
    118
    Vote Rating
    0
    mtarantini is on a distinguished road

      0  

    Default


    Okay thx,

    But is it something that you can implement ?
    Or do I have to listen to the Bind Event and bind my fields manually ?
    Last edited by mtarantini; 30 Dec 2009 at 8:13 AM. Reason: delete

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You can also add the two fields that are part of the multifield dynamically to the binding.
    That is the easiest what you can do. Simple create a fieldbinding for both fields of the multifield and add them to the binding.


    What you are looking for cannot be implemented because it is too custom to work for everyone.

  5. #5
    Sencha User
    Join Date
    May 2009
    Posts
    118
    Vote Rating
    0
    mtarantini is on a distinguished road

      0  

    Default


    Thx for you're help, it's working like a charm.

    I add those line :

    Code:
    ...
    
    FieldBinding fbForName = new FieldBinding(nameFieldForMultiField, ModelA.NAME);
    FieldBinding fbForDescription = new FieldBinding(descriptionFieldForMultiField,ModelA.MODELB + "." + ModelB.DESCRIPTION);
    
    ...
    
    binding.addFieldBinding(fbForName);
    binding.addFieldBinding(fbForDescription);
    And it's working perfectly.

    And what about the Form isValid method ? Do I have to write a custom Validator as well ?
    Because it's seems to works, but only the first field of the multifield turns red if it's empty..
    Last edited by mtarantini; 30 Dec 2009 at 8:21 AM. Reason: mise en forme

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You will need to write some validation service for the multifield. Multifield is a "baseclass". you hsould never use it standalnoe without adding the functionality you need.

  7. #7
    Sencha User
    Join Date
    May 2009
    Posts
    118
    Vote Rating
    0
    mtarantini is on a distinguished road

      0  

    Default


    Okay, understood.

    Thx for the explanations!

Thread Participants: 1