Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    Originally posted by Isomorphic
    What StackExceptions are you getting? If you're ever getting an error, you always need to post it.

    You seem to be assuming "record" will be non-null if displayValue is null, this is not necessarily the case.

    Also, "record" is the values currently being edited in the form, *not* the selected record, which, if a record has been selected, is available from getSelectedRecord().
    I was getting the too much recursion error, I had to set a jvm param of -Xss1M to see that since it keeps calling it (prob the reason for the recursion error).

    I want the formatter to return using these values (displayValue+"-"+value) should I do it another way?
    Should I be using the record or something else instead inside that Formatter?

    return item.getDisplayValue() + " - " + item.getValue();



    You also stated :
    Originally posted by Isomorphic
    Note that at some points, the displayValue is not available (eg, immediately after a setValue() call, before fetchMissingValues has done it's job). Your formatter will be automatically called again when the displayValue has been loaded.
    How do I handle when it isn't available?

    Currently I still get the error but it eventually shows on the screen using this code , however it seems to be appending over and over again...(I've tried every variation and looked through the forum as to how I need to set the formatter properly but to no avail)

    Code:
    FormItemValueFormatter xmlidFmt = new FormItemValueFormatter() {
    			
    			@Override
    			public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
    				if(value == null) return "";
    				String tmp = value.toString();
    				if(item.getDisplayValue() != null && item.getDisplayValue().trim().length() > 0) {
    					tmp = item.getDisplayValue() + " - " + value;
    				}
    				return tmp;
    			}
    		};
    		SelectItem tmp = new SelectItem("xmlid");
    		tmp.setValueFormatter(xmlidFmt);
    		
    		df.setFields(tmp);

    Comment


      #17
      OK, confusion was our fault - formItem.getDisplayValue() is of course calling your formatter to find out what to display. Hence infinite recursion. What we meant to say was to get the displayValue from the record.

      What fetchMissingValues does is establish a "selected record" just like an end user picking from the drop-down list.

      So all you need to do is check for a selected record (getSelectedRecord()) and if available, use the displayValue from that record (record.getAttribute("displayFieldName"). If no record is available, return the stored value instead (passed to you).

      Comment


        #18
        Originally posted by Isomorphic
        OK, confusion was our fault - formItem.getDisplayValue() is of course calling your formatter to find out what to display. Hence infinite recursion. What we meant to say was to get the displayValue from the record.

        What fetchMissingValues does is establish a "selected record" just like an end user picking from the drop-down list.

        So all you need to do is check for a selected record (getSelectedRecord()) and if available, use the displayValue from that record (record.getAttribute("displayFieldName"). If no record is available, return the stored value instead (passed to you).
        I don't have a ListGrid available(I'm using a DynamicForm) ...can I use something else or is there another way to get ...getSelectedRecord?

        I don't see getSelectedRecord on any of my other objects in the formatter, which should it be on do I have make a cast or something?
        Last edited by gilcollins; 9 Aug 2010, 09:40.

        Comment


          #19
          Originally posted by Isomorphic
          OK, confusion was our fault - formItem.getDisplayValue() is of course calling your formatter to find out what to display. Hence infinite recursion. What we meant to say was to get the displayValue from the record.

          What fetchMissingValues does is establish a "selected record" just like an end user picking from the drop-down list.

          So all you need to do is check for a selected record (getSelectedRecord()) and if available, use the displayValue from that record (record.getAttribute("displayFieldName"). If no record is available, return the stored value instead (passed to you).
          I don't have a ListGrid available(I'm using a DynamicForm) ...is there another way to get this?

          Comment


            #20
            If you're having trouble finding APIs in the Java, try a site-specific search like this.

            Comment


              #21
              Originally posted by Isomorphic
              If you're having trouble finding APIs in the Java, try a site-specific search like this.
              That is really helpful however my FormItem doesn't have it available but the API say's it does, was it newly added?

              http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/widgets/form/fields/FormItem.html

              I'm still on 2.1 due to this issue :
              http://code.google.com/p/smartgwt/issues/detail?id=490

              Comment


                #22
                That other issue you're reporting comes from using a FormItem that supplies AdvancedCriteria. Most likely, you have the filterEditor enabled with a "date" field. To avoid AdvancedCriteria being generated (assuming here your code cannot handle it), setFilterEditorType() on the "date" field to a DateItem (instead of the default DateRangeItem).

                Comment


                  #23
                  Originally posted by Isomorphic
                  That other issue you're reporting comes from using a FormItem that supplies AdvancedCriteria. Most likely, you have the filterEditor enabled with a "date" field. To avoid AdvancedCriteria being generated (assuming here your code cannot handle it), setFilterEditorType() on the "date" field to a DateItem (instead of the default DateRangeItem).
                  Yes the reason I couldn't upgrade was that I was doing (shown in code block) :

                  But I also have Date and DateTime types however they come across as null (I'm guessing since they don't have a ListGridFieldType they can map to).

                  Code:
                  ListGridField[] lgfs = lgLocal.getAllFields();
                  if(lgfs != null) {
                  	for (int i = 0; i < lgfs.length; i++) {
                  		ListGridFieldType lgft = lgfs[i].getType();
                  		if(lgft == ListGridFieldType.TEXT || lgft == ListGridFieldType.INTEGER) {
                  			lgfs[i].setFilterEditorType(new TextItem());
                  		}
                         }
                  }
                  I added this and now my Criteria is back to the mapped way it was in 2.1 :

                  Code:
                  else if(lgft == null) {
                  	lgfs[i].setFilterEditorType(new TextItem());
                  }
                  And now I have FormItem.getSelectedRecord since I have the application working on 2.2.

                  The formatter still doesn't work until after I make a new selection, before the selection it only shows the value then refreshes to the description. After I make a selection it shows as "description - value" like I want but I would like to see that when it's drawn to the page instead of after I change it if possible.

                  This is what I ended up using for the formatter based on your replies, maybe there's something I need to change?
                  Code:
                  FormItemValueFormatter xmlidFmt = new FormItemValueFormatter() {
                  			
                  			@Override
                  			public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
                  				if(item.getSelectedRecord() != null) {
                  					return item.getSelectedRecord().getAttribute("dsc") + "-" + item.getSelectedRecord().getAttribute("xmlid");
                  				}
                  				if(value == null) return "";
                  				return value.toString();
                  			}
                  		};
                  Thank you,

                  Comment


                    #24
                    Before the pickList is shown, if the formItem is given a value, fetchMissingValues (on by default) fetches the (single) record and establishes it as the selected record, then calls your formatter again.

                    So:

                    1. check that you haven't disabled fetchMissingValues

                    2. look for the request initiated by fetchMissingValues in the RPC tab and check that you're sending a valid response

                    Comment


                      #25
                      Originally posted by Isomorphic
                      Before the pickList is shown, if the formItem is given a value, fetchMissingValues (on by default) fetches the (single) record and establishes it as the selected record, then calls your formatter again.

                      So:

                      1. check that you haven't disabled fetchMissingValues

                      2. look for the request initiated by fetchMissingValues in the RPC tab and check that you're sending a valid response
                      I've ensured that it is set to true, I've gone to the RPC tab and it's never shown me anything before or now...maybe I need to configure something for this tab to work?

                      I have Track RPCs checked and Auto-Scroll checked currently.

                      Comment


                        #26
                        You're probably using GWTRPCDataSource? The RPC tab doesn't track that kind of RPC. This is one of many reasons we don't recommend using GWT-RPC (see the FAQ).

                        Use whatever debugging approach occurs to you - the problem here appears to be that your DataSource is not responding correctly to the fetch initiated by fetchMissingValues.

                        Comment


                          #27
                          Originally posted by Isomorphic
                          You're probably using GWTRPCDataSource? The RPC tab doesn't track that kind of RPC. This is one of many reasons we don't recommend using GWT-RPC (see the FAQ).

                          Use whatever debugging approach occurs to you - the problem here appears to be that your DataSource is not responding correctly to the fetch initiated by fetchMissingValues.
                          The data is being retrieved that's why when it first shows it has the value 300710 (I can see this in debug since it's slow) after it's done retrieving it shows the description "CSR Guest Feedback" but it doesn't show the two like I have in my Formatter unless you pick it from the SelectItem afterwards.

                          Comment


                            #28
                            Any update, the data is being pulled from the back end as per my previous post so that shouldn't be the issue.

                            I've also recently downloaded the latest nightly from a few days ago, which fixed some other issues, but this one is still not working.

                            Comment


                              #29
                              So once again, the problem here appears to be that your DataSource is not responding correctly to the fetch initiated by fetchMissingValues. The fact that it correctly responds to some *other* fetch isn't relevant. So add some logging to your server code so you can trace out this fetch and see what's wrong.

                              Comment


                                #30
                                Originally posted by Isomorphic
                                So once again, the problem here appears to be that your DataSource is not responding correctly to the fetch initiated by fetchMissingValues. The fact that it correctly responds to some *other* fetch isn't relevant. So add some logging to your server code so you can trace out this fetch and see what's wrong.
                                As I stated earlier this fetchMissingValues is being called and is getting a valid response.

                                When the form first loads it has many values that get filled in, this particular one "xmlid" is stored as a number on the backend and is displayed as a number until the fetchMissingValues is called then it retrieves the "dsc" field as it's display which in one particular case changes the number from : 300710 to "CSR Guest Feedback" if I .setFetchMissingValues(true); if I set it to false then it stays as the 300710, so it is working.

                                I've also tried walking through the code and item.getSelectedRecord is always null in the formatValue (until you make a selection from the dropdown attached to this SelectItem), which I believe is the issue (code below):

                                Added a short video to see what I'm talking about this is with setFetchMissingValues(true) with it false it stay's as a number.
                                http://www.screencast.com/t/MTU5MGVmNjA

                                Code:
                                FormItemValueFormatter xmlidFmt = new FormItemValueFormatter() {
                                			
                                	@Override
                                	public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
                                		if(item.getSelectedRecord() != null) {
                                			return item.getSelectedRecord().getAttribute("dsc") + "-" + item.getSelectedRecord().getAttribute("xmlid");
                                		}
                                		if(value == null) return "";
                                		return value.toString();
                                	}
                                };
                                Thank you,
                                Last edited by gilcollins; 12 Aug 2010, 12:53.

                                Comment

                                Working...
                                X