1 Reply Latest reply on Jun 6, 2010 1:35 AM by deanhiller2000

    how to keep converter in conversation?

    deanhiller2000

      I have the strangest issue on my converter.  I see it in the conversation on the debug page, but if I go to the page with my pulldown it loads from one instance of my converter and then when I click save, it uses a different instance of the converter :(.  My converter is this(notice I started scoping the field in inside too trying to get this too work).


      odd note is the debug.xhtml page before save button and after shows the toString of converter to be the same(toString usually prints hashCode which would be different if instance changed) so why is my seam changing instances but debug page shows it's not....OH, I print out the conversation number and it prints the same conversation before and after save button.


      @Name("projectDtoConverter")
      @Scope(ScopeType.CONVERSATION)
      @BypassInterceptors
      @org.jboss.seam.annotations.faces.Converter
      public class ProjectDtoConverter implements Converter {
      
           @In(required=false)
           @Out(scope=ScopeType.CONVERSATION)
           private Map<String, ProjectDto> nameToProjectDto;
           
           @Override
           public Object getAsObject(FacesContext ctx, UIComponent comp, String s) {
                return getMap().get(s);
           }
      
           @Override
           public String getAsString(FacesContext ctx, UIComponent comp, Object obj) {
                ProjectDto proj = (ProjectDto) obj;
                getMap().put(proj.getFullName(), proj);
                return proj.getFullName();
           }
      
           private Map<String, ProjectDto> getMap() {
                if(nameToProjectDto == null) {
                     Logger log = Logger.getLogger("logger2");
                     nameToProjectDto = new HashMap<String, ProjectDto>();
                     log.info("conversation="+Conversation.instance().getId());
                     log.info("done");
                }
                return nameToProjectDto;
           }
      
      }
      



      any ideas at all?