Can someone please comment if these changes are OK or not? Also, can I have
commit access on http://svn.apache.org/repos/asf/wicket/trunk/jdk-1.4/? My
SourceForge.net id is mohan_shenoy.



mohan.shenoy wrote:
> 
> These were some changes we had made. I want to contribute them back to the
> project. My comments are in bold.
> 
> 
> mohan.shenoy wrote:
>> 
>> I have made some improvements in my working copy. I am attaching the diff 
>> file.
>> 
>> 
>> I am looking forward to your questions and comments.
>> 
>> Thanks,
>> Mohan
>> 
>> I thought it would be better to do localization at a higher level like
>> wicket.markup.html.form.IChoiceRenderer implementation.
>> Index:
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java
>> ===================================================================
>> ---
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java
>> (revision 609566)
>> +++
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java
>> (working copy)
>> @@ -78,7 +78,6 @@
>>                      Object displayValue = renderer.getDisplayValue(choice);
>>                      Class displayClass = displayValue == null ? null :
>> displayValue.getClass();
>>                      String value =
>> getConverter(displayClass).convertToString(displayValue, getLocale());
>> -                    value = getLocalizer().getString(id + "." + value, 
>> this, value);
>>  
>>                      buffer.append("\n<option 
>> value=\"").append(id).append("\"");
>> 
>> This adds a convinience method to clear all selections 
>> Index:
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/Recorder.java
>> ===================================================================
>> ---
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/Recorder.java
>> (revision 609566)
>> +++
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/Recorder.java
>> (working copy)
>> @@ -205,5 +205,13 @@
>>                      ids = value.split(",");
>>              }
>>      }
>> +    
>> +    /**
>> +     * Clears all the selections
>> +     */
>> +    public void clearSelections() 
>> +    {
>> +            updateIds("");
>> +    }
>>  
>>  }
>> 
>> This adds a convinience method to get and set the "required" property
>> http://www.nabble.com/palette-validator-to6289839.html#a6289839
>> Index:
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java
>> ===================================================================
>> ---
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java
>> (revision 609566)
>> +++
>> E:/svn/wicket/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java
>> (working copy)
>> @@ -252,6 +252,22 @@
>>      {
>>              return getRecorderComponent().getUnselectedChoices();
>>      }
>> +    
>> +    /**
>> +     * Mark this palette as required on the form, which means that
>> +     * items must be selected.
>> +     * <p>
>> +     * This just sets the required flag on the underlying recorder field.
>> +     */
>> +    public void setRequired(boolean required)
>> +    {
>> +        getRecorderComponent().setRequired(required);
>> +    }
>> +    
>> +    public boolean isRequired()
>> +    {
>> +        return getRecorderComponent().isRequired();
>> +    }
>>  
>>  
>>      /**
>> 
>> 
>> This adds 2 translation comments
>> NLS_MESSAGEFORMAT_VAR Strings which contain replacement variables are
>> processed by the MessageFormat class (single quote must be coded as 2
>> consecutive single quotes ''). Strings which do NOT contain replacement
>> variables are NOT processed by the MessageFormat class (single quote must
>> be coded as 1 single quote ').  
>> NLS_ENCODING Specifies the encoding used
>> 
>> Index:
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.properties
>> ===================================================================
>> ---
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.properties
>> (revision 609566)
>> +++
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.properties
>> (working copy)
>> @@ -12,6 +12,10 @@
>>  #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>>  #  See the License for the specific language governing permissions and
>>  #  limitations under the License.
>> +
>> +# NLS_MESSAGEFORMAT_VAR
>> +# NLS_ENCODING=UNICODE
>> +
>>  Required=Field '${label}' is required.
>>  IConverter='${input}' is not a valid ${type}.
>>  
>> Add support for Bookmarkable Page Link
>> Index:
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
>> ===================================================================
>> ---
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
>> (revision 609566)
>> +++
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
>> (working copy)
>> @@ -506,7 +506,13 @@
>>       */
>>      public Result isPageLink(String path, Class expectedPageClass)
>>      {
>> -            PageLink pageLink = 
>> (PageLink)getComponentFromLastRenderedPage(path);
>> +            Link link = (Link)getComponentFromLastRenderedPage(path);
>> +            if (link instanceof BookmarkablePageLink)
>> +            {
>> +                    return isEqual(expectedPageClass, 
>> ((BookmarkablePageLink)
>> link).getPageClass());
>> +            }
>> +
>> +            PageLink pageLink = (PageLink) link;
>>              try
>>              {
>>                      Field iPageLinkField =
>> pageLink.getClass().getDeclaredField("pageLink");
>> 
>> 
>> Catches user error in form component lookup.
>> Gets Palette selection working with FormTester
>> 
>> Index:
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
>> ===================================================================
>> ---
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
>> (revision 609566)
>> +++
>> E:/svn/wicket/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
>> (working copy)
>> @@ -19,6 +19,7 @@
>>  import java.lang.reflect.Field;
>>  import java.lang.reflect.InvocationTargetException;
>>  import java.lang.reflect.Method;
>> +import java.util.ArrayList;
>>  import java.util.Arrays;
>>  import java.util.Collection;
>>  import java.util.HashMap;
>> @@ -476,6 +477,10 @@
>>      {
>>              checkClosed();
>>              FormComponent component =
>> (FormComponent)workingForm.get(formComponentId);
>> +            if (component == null) 
>> +            {
>> +                    throw new IllegalArgumentException("No such component 
>> '" +
>> formComponentId + "' in form: " + workingForm);
>> +            }
>>  
>>              ChoiceSelector choiceSelector =
>> choiceSelectorFactory.create(component);
>>              choiceSelector.doSelect(index);
>> @@ -516,13 +521,53 @@
>>      {
>>              checkClosed();
>>  
>> -            ChoiceSelector choiceSelector =
>> choiceSelectorFactory.createForMultiple((FormComponent)workingForm.get(formComponentId));
>> +            // This is a hack to get Palette selection working with 
>> FormTester.
>> +            // Note we can't reference the palette class directly since 
>> FormTester
>> +            // is in wicket and Palette is in wicket-extensions so we need 
>> to do
>> +            // some acrobatics to deal with this.
>> +            Component c = (Component) workingForm.get(formComponentId);
>> +            if (!(c instanceof FormComponent)) 
>> +            {
>> +                    // Palette is not a FormComponent
>> +                    FormComponent recorder = (FormComponent)
>> workingForm.get(formComponentId + ":recorder");
>> +                    String recorderValue = recorder.getValue();
>> +                    IChoiceRenderer renderer = 
>> (IChoiceRenderer)callGetter(c,
>> "getChoiceRenderer");
>> +                    Collection choices = (Collection)callGetter(c, 
>> "getChoices");
>> +                    List choiceList = new ArrayList(choices);
>> +                    for (int i = 0; i < indexes.length; i++)
>> +                    {
>> +                            int j = indexes[i];
>> +                            Object value = choiceList.get(j);
>> +                            String val = renderer.getIdValue(value, j);
>> +                            recorderValue += val; 
>> +                            if (i + 1 < indexes.length) 
>> +                            {
>> +                                    recorderValue += ",";
>> +                            }
>> +                    }
>> +                    setFormComponentValue(recorder, recorderValue);
>> +                    return;
>> +            }
>> +            FormComponent fc = (FormComponent) c;
>> +            ChoiceSelector choiceSelector =
>> choiceSelectorFactory.createForMultiple(fc);
>>  
>>              for (int i = 0; i < indexes.length; i++)
>>              {
>>                      choiceSelector.doSelect(indexes[i]);
>>              }
>>      }
>> +    
>> +    private Object callGetter(Object self, String method) {
>> +            try
>> +            {
>> +                    Method m = self.getClass().getMethod(method, null);
>> +                    return m.invoke(self, null);
>> +            }
>> +            catch (Exception e)
>> +            {
>> +                    throw new RuntimeException(e);
>> +            }
>> +    }
>>  
>>      /**
>>       * Simulates filling in a field on a <code>Form</code>.
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Wicket-1.3-tp14664035p14797291.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to