GWT – [ERROR] Line 20: Too many parameters, parameter arg254 is exceeding the limit of 255 words eligible for method parameters

I was creating a widget today, using UiBinder, which consisted mainly of an HTML table.  My table consisted of over 55 rows, where each row looked like this:

  <tr class="{style.table-odd-row}">
      <th class="{style.table-th}"><span ui:field="field1Label"/></th>
      <td class="{style.table-td}"><g:InlineLabel ui:field="field1"/></td>
  </tr>

When I compiled, I received this error:

[exec] [INFO]    [ERROR] Errors in 'C:\Projects\<OMITTED>\MyTableWidget_MyTableWidgetUiBinderImpl.java'
[exec] [INFO]    [ERROR] Line 20: Too many parameters, parameter arg254 is exceeding the limit of 255 words eligible for method parameters

I decided to look at the generated file (MyTableWidget_MyTableWidgetUiBinderImpl.java) that the compiler was complaining about.  This is Line 20:

SafeHtml html1(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6, <OMITTED FOR BREVITY>, String arg254, String arg255, <OMITTED FOR BREVITY>, String arg282, String arg283);

Sure enough, a method had over 255 parameters!  This is a javac limitation, as opposed to a GWT limitation.

I am not that familiar with the UiBinder code generation process, so first of all, I needed to determine what is causing that method to have so many parameters.  In the same generated file, I found this HTML for each row in the table:

<tr class='{162}'> <th class='{163}'><span id='{164}'></span></th> <td class='{165}'><span id='{166}'></span></td> </tr>

This showed me that each row in my table was generating 5 arguments.  3 of them were for styling table elements and 2 were for the ui:field elements that were converted to ‘id’ attributes.

As I mentioned above, my table had over 55 rows.  55 rows x 5 arguments per row = 275 arguments.

I need to fix this quickly, so my two options at this point are to simply my styling or divide my widget into multiple widgets.  Either should work.

Advertisements

About stevewall123

I am a Lead Software Engineer in Minneapolis working for Thomson Reuters. I am currently working on projects using Java, JavaScript, Spring, Drools, Hazelcast, Liquibase and Tomcat. Previously, I used C#, GWT, Grails, Groovy, JMS and JBoss Drools Guvnor. In the past I have worked on projects using J2EE, Swing, Webwork, Hibernate, Spring, Spring-WS, JMS, JUnit and Ant.
This entry was posted in GWT, UiBinder and tagged , . Bookmark the permalink.

4 Responses to GWT – [ERROR] Line 20: Too many parameters, parameter arg254 is exceeding the limit of 255 words eligible for method parameters

  1. Ashton says:

    I just ran into this issue. I was just using many div’s. Do you have any more insight into this?? The workaround by just wrapping portions in something like a HTMLPanel work just fine, but I’m curious as to how this get’s compiled down eventually creating a method with 255 parameters… sorry, I’m not too familiar with how UiBinder works under the hood. What portions end up being the params, etc? Thanks for the tip to wrap in separate widgets

    • stevewall123 says:

      The params come from anything that GWT needs to make a substitution on. In this case, that is for any ui:field attributes and any GWT style declarations (e.g. class=”{style.someStyle}”).

      • Ashton says:

        Sorry for my ignorance here but does that translate to each UiBinder having just one method to set all properties? myUiBinder.setValues(ui1, ui2, ui3, styl1, styl2, …..) or something along those lines? Thanks again!

      • stevewall123 says:

        I would recommend that you look at the generated file where you receive the compilation error at. It will make much more sense to you. But short answer: yes, it creates a method with all those parameters.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s