Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-2443

Setting values in UIInputMany doesn't affect UI

    XMLWordPrintable

Details

    • Hide

      Create an Addon which changes InputMany value everytime a directory is selected in another UIInput:

      Bar.java
          @Inject
          @WithAttributes(label = "Select Files")
          private UIInputMany<FileResource<?>> files;
      
          @Inject
          @WithAttributes(label = "Select dir")
          private UIInput<DirectoryResource> dir;
          
          UIOutput out;
       
      
              @Override
      	public void initializeUI(UIBuilder uiBuilder) throws Exception {
      
      		dir.addValueChangeListener(new ValueChangeListener() {
      
      			@Override
      			public void valueChanged(ValueChangeEvent event) {
      				List<FileResource<?>> fileList = (List<FileResource<?>>) files.getValue();
      				
      				
      				DirectoryResource selectedDir = (DirectoryResource) event.getNewValue();
      				for (Resource<?>  resource : selectedDir.listResources()) {
      					FileResource<?> fileToAdd = resource.reify(FileResource.class);
      					if(fileToAdd != null && fileToAdd.exists() && !fileList.contains(fileToAdd)){
      						fileList.add(fileToAdd);
      					}
      				}
      				//files.setValue(fileList);
      				for (FileResource<?> fileResource : ((List<FileResource<?>>) files.getValue())) {
      					out.out().println(fileResource.getName());
      				}
      
      			}
      
      		});
      		uiBuilder.add(dir).add(files);
      	}
      
      
      Show
      Create an Addon which changes InputMany value everytime a directory is selected in another UIInput: Bar.java @Inject @WithAttributes(label = "Select Files" ) private UIInputMany<FileResource<?>> files; @Inject @WithAttributes(label = "Select dir" ) private UIInput<DirectoryResource> dir; UIOutput out; @Override public void initializeUI(UIBuilder uiBuilder) throws Exception { dir.addValueChangeListener( new ValueChangeListener() { @Override public void valueChanged(ValueChangeEvent event) { List<FileResource<?>> fileList = (List<FileResource<?>>) files.getValue(); DirectoryResource selectedDir = (DirectoryResource) event.getNewValue(); for (Resource<?> resource : selectedDir.listResources()) { FileResource<?> fileToAdd = resource.reify(FileResource.class); if (fileToAdd != null && fileToAdd.exists() && !fileList.contains(fileToAdd)){ fileList.add(fileToAdd); } } //files.setValue(fileList); for (FileResource<?> fileResource : ((List<FileResource<?>>) files.getValue())) { out.out().println(fileResource.getName()); } } }); uiBuilder.add(dir).add(files); }

    Description

      Trying to change/set value on a UIInputMany doesnt updates the UI.

      I've created a small video which shows the issue: https://www.youtube.com/watch?v=waJRpyGXIcw

      Attachments

        Activity

          People

            Unassigned Unassigned
            procergs-std Mauricio Wodarski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: