You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Sven Homburg (JIRA)" <de...@tapestry.apache.org> on 2008/03/18 21:11:25 UTC

[jira] Created: (TAPESTRY-2278) BlankOption value in Select component should be configurable

BlankOption value in Select component should be configurable
------------------------------------------------------------

                 Key: TAPESTRY-2278
                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
             Project: Tapestry
          Issue Type: Improvement
          Components: tapestry-core
    Affects Versions: 5.0.11
            Reporter: Sven Homburg
             Fix For: 5.0.12


i often use the option value of a select component holding id's for database entities.
the id's type are most numeric values, so my problem is: 

i attached an ajax request that sends each change from the select component.
the following method catch the event

    @OnEvent(component = "inputProject", value = "change")
    JSONValue projectIdChanged(long projectId)
    {
       .....
        return mapper.toJSON(resultList);
    }

if the user select the blank option
the component throws a NumberFormatException

so it were cool, if i declare the empty option value by my self.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Closed: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship closed TAPESTRY-2278.
------------------------------------------

    Resolution: Invalid
      Assignee: Howard M. Lewis Ship

When generating your SelectModel, you should include your own blank option with value "0" to get the behavior you desire.  Alternately, change the parameter type from long to String and do your own parse to long (along with a check).  But don't expect Tapestry to treat the empty string exactly like the number zero, that is a bad idea.

> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>            Assignee: Howard M. Lewis Ship
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Sven Homburg (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580801#action_12580801 ] 

Sven Homburg commented on TAPESTRY-2278:
----------------------------------------

ok, i think you can close this issue.

i have readed the documentation again (more closely) and now i trip over the "onValidateFrom..." method
i think that is the right point to checkout input errors.

the complexity of a whole web application may sometimes too much for an "one man show" like me.
databases, javascript, java, html, tap3 and tap5 ... ;-)

thanx for your effort.

> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580566#action_12580566 ] 

Howard M. Lewis Ship commented on TAPESTRY-2278:
------------------------------------------------

Let me see if I understand.

You want a blank option present, because you want to force the user to actively make a selection, rather than just whatever ends up visible in the project <select>.

However, if the user submits the form, the problem is that the blank value is not valid to be converted into an id (int or long).

My question: why is the <select> not a required field?  That would force the user to make a selection on the client side which would prevent the scenario where an unexpected blank value is submitted in the form.

But I think you are correct, a blank or null update from the user does need to be recognized and handled correctly.  But was is correctly?  Ignored outright, or treated as a null?  And, if null, that may cause its own exceptions if assigned to a primitive field (int) rather than a wrapper field (Integer).

> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580838#action_12580838 ] 

Howard M. Lewis Ship commented on TAPESTRY-2278:
------------------------------------------------

I'm still thinking there may be more than "user error" going on here, so I'll leave this open a bit longer.  It does sound to me like blank value handlng with Select is not quite right; it should be pushing a null into the value parameter I think, rather than throwing an NPE.

> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580171#action_12580171 ] 

Howard M. Lewis Ship commented on TAPESTRY-2278:
------------------------------------------------

Isn't this juse blankoption="never" ?

> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Sven Homburg (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580208#action_12580208 ] 

Sven Homburg commented on TAPESTRY-2278:
----------------------------------------

i dont think so (in my situation),
sample: i have to select able fields 
field "two" depends on the selected value of field "two"

<select id="category">
  <option value="1" selected>Category One</option>
  <option value="2">Category Two</option>
</select>

<select id="project">
</select>

if user selects category two i send an ajax request to find all projects for category id 2
and put the resultset via JSON into the project selcetor.
in my case i dont want that one project ist "pre-selected" (if i use BlankOption.NEVER),
 because my users than submit the form with pre-selected project value  without turn on their brain.

in the moment  i must use a trick: add a dummy entry to my selectmodel with id like -1 or 0

i hope you understand my "germano-americano" ;-)


> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Commented: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Sven Homburg (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12582487#action_12582487 ] 

Sven Homburg commented on TAPESTRY-2278:
----------------------------------------

i am back ;-)
i think this little sample shows my problem

rendered by tap5 (here symplified):
<select id="mySelect" onChange="location=/mts/freightorder/edit.inputcustomer:change">
  <option value=""></option>
  <option value="1">customer 1</option>
  <option value="2">customer 2</option>
  <option value="3">customer 3</option>
</select>

page class (partial):

    @OnEvent(component = "inputCustomer", value = "change")
    JSONObject customerSelected(Long value)
    {
        JSONObject json = new JSONObject();
        json.put("found", false);

        if (value != null)
        {
            Customer customer = (Customer) getDAO(Customer.class).doRetrieve(value, false);
            if (customer != null)
            {
                json.put("found", true);
                json.put("street", customer.getAddress().getStreet());
                json.put("location", customer.getAddress().getZip() + " " + customer.getAddress().getCity());
                json.put("phone", customer.getAddress().getPhone1());
                json.put("fax", customer.getAddress().getFax1());
                json.put("email", customer.getAddress().getEmail1());

                _entity.setCustomer(customer);
            }
        }

        return json;
    }

if user choices the blank option tapestry throws an NFE.
if i could set the blank option value to "0", so i can react in this event method



> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship updated TAPESTRY-2278:
-------------------------------------------

    Fix Version/s:     (was: 5.0.12)

> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>            Assignee: Howard M. Lewis Ship
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Issue Comment Edited: (TAPESTRY-2278) BlankOption value in Select component should be configurable

Posted by "Sven Homburg (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580208#action_12580208 ] 

homburgs edited comment on TAPESTRY-2278 at 3/18/08 6:34 PM:
-----------------------------------------------------------------

i dont think so (in my situation),
sample: i have to select able fields 
field "project" depends on the selected value of field "category"

<select id="category">
  <option value="1" selected>Category One</option>
  <option value="2">Category Two</option>
</select>

<select id="project">
</select>

if user selects category two i send an ajax request to find all projects for category id 2
and put the resultset via JSON into the project selcetor.
in my case i dont want that one project ist "pre-selected" (if i use BlankOption.NEVER),
 because my users than submit the form with pre-selected project value  without turn on their brain.

in the moment  i must use a trick: add a dummy entry to my selectmodel with id like -1 or 0

i hope you understand my "germano-americano" ;-)


      was (Author: homburgs):
    i dont think so (in my situation),
sample: i have to select able fields 
field "two" depends on the selected value of field "two"

<select id="category">
  <option value="1" selected>Category One</option>
  <option value="2">Category Two</option>
</select>

<select id="project">
</select>

if user selects category two i send an ajax request to find all projects for category id 2
and put the resultset via JSON into the project selcetor.
in my case i dont want that one project ist "pre-selected" (if i use BlankOption.NEVER),
 because my users than submit the form with pre-selected project value  without turn on their brain.

in the moment  i must use a trick: add a dummy entry to my selectmodel with id like -1 or 0

i hope you understand my "germano-americano" ;-)

  
> BlankOption value in Select component should be configurable
> ------------------------------------------------------------
>
>                 Key: TAPESTRY-2278
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2278
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.0.11
>            Reporter: Sven Homburg
>             Fix For: 5.0.12
>
>
> i often use the option value of a select component holding id's for database entities.
> the id's type are most numeric values, so my problem is: 
> i attached an ajax request that sends each change from the select component.
> the following method catch the event
>     @OnEvent(component = "inputProject", value = "change")
>     JSONValue projectIdChanged(long projectId)
>     {
>        .....
>         return mapper.toJSON(resultList);
>     }
> if the user select the blank option
> the component throws a NumberFormatException
> so it were cool, if i declare the empty option value by my self.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org