| Remove the null values in a multi-value listbox [message #690033] |
Tue, 28 June 2011 16:16  |
Scroon Messages: 28 Registered: June 2011 |
Junior Member |
|
|
Hi,
Each time I create a parameter with multi-value checked and is-required unchecked, and make its display type as listbox, the first value in the listbox will always be a blank, and the second value is always be "Null Value" , (both static or dynamic parameter),I have tried a lot of different ways to remove it but none of them works.
I modified ComboBoxParameterFragment.jsp in webapps\birt\webcontent\birt\pages\parameter, replace the IBirtConstants.NULL_VALUE in line 143, and IBirtConstants.NULL_VALUE_DISPLAY in line 144 with "123":
String outputValue = ParameterAccessor.htmlEncode(( value == null)?"123":value);
String outputLabel = ParameterAccessor.htmlEncode(( label == null)?"123":label);
then run the report again, the blank and null value is still there....
Then I do sth like:
String outputValue = ParameterAccessor.htmlEncode(( value == null)?IBirtConstants.NULL_VALUE:value);
String outputLabel = ParameterAccessor.htmlEncode(( label == null)?"123":"123");
This time all the values in the list box became display as "123", but the blank line and "Null Value" are still there, in the first and second line of the parameter list box!
An interesting thing is: when I check the is-required, the blank and null-value will all gone...
I'm using birt-runtime-2_6_2, and same problem with 3.7
[Updated on: Tue, 28 June 2011 16:19] Report message to a moderator
|
|
|
| Re: Remove the null values in a multi-value listbox [message #690055 is a reply to message #690033] |
Tue, 28 June 2011 17:33   |
Jason Weathersby Messages: 9167 Registered: July 2009 |
Senior Member |

|
|
This section of the JSP
if ( parameterBean.getSelectionList( ) != null )
{
if( !parameterBean.isRequired( ) || ( parameterBean.isCascade( ) &&
DataUtil.trimString( defaultValue ).length( )<=0 ) )
{
if( allowMultiValue && DataUtil.contain( values, "", true ) )
{
%>
<OPTION SELECTED></OPTION>
<%
}
else
{
%>
<OPTION></OPTION>
<%
}
}
Adds a blank option not the null.
To remove the null enter this code right after 144
boolean nullvl = false;
if( value == null ){
nullvl = true;
}
if( !nullvl ){
Close off the if statement right before the end of the for loop.
Jason
On 6/28/2011 4:16 PM, Scroon wrote:
> Hi,
>
> Each time I create a parameter with multi-value checked and is-required
> unchecked, and make its display type as listbox, the first value in the
> listbox will always be a blank, and the second value is always be "Null
> Value" , (both static or dynamic parameter),I have tried a lot of
> different ways to remove it but none of them works.
>
> I modified ComboBoxParameterFragment.jsp in
> webapps\birt\webcontent\birt\pages\parameter, replace the
> IBirtConstants.NULL_VALUE in line 143, and
> IBirtConstants.NULL_VALUE_DISPLAY in line 144 with "123", then run the
> report again, the blank and null value is still there....
>
> Then I do sth like:
> String outputValue = ParameterAccessor.htmlEncode(( value ==
> null)?IBirtConstants.NULL_VALUE:value);
> String outputLabel = ParameterAccessor.htmlEncode(( label ==
> null)?IBirtConstants.NULL_VALUE_DISPLAY:"123");
>
> This time all the values in the list box became display as "123", but
> the blank line and "Null Value" are still there, in the first and second
> line of the parameter list box!
>
>
> An interesting thing is: when I check the is-required, the blank and
> null-value will all gone...
>
> I'm using birt-runtime-2_6_2, and same problem with 3.7
Jason Weathersby
BIRT Exchange
|
|
|
|
| Re: Remove the null values in a multi-value listbox [message #1007916 is a reply to message #690063] |
Fri, 08 February 2013 03:09   |
David Good Messages: 33 Registered: September 2012 |
Member |
|
|
Yes, thanks Jason this also got me out of a bind.
I did find that the sample viewer still listed a 'Null Value' entry for non required cascading parameters when they were reloaded after a parent parameter re-selection.
I modified the AbstractParamDialog.js file so it skipped the entry when rebuilding the select list. This works for non required cascading parameters only I am working o am fix for this, if anyone has any ideas??.
line 112:
if (i!=1) { // start remove 'Null Value' condition
then add another brace just before the for loop's closing brace
} // end remove 'Null Value' condition
Also, if you want to keep the entries ('Null Value' and blank), but customize their text you can edit them in the same for loop:
(DO NOT add 'Null Value' condition mentioned above though)
if( oLabel ) {
oOption.text = oLabel.data;
if (oOption.text=="Null Value") oOption.text="Custom value can be added here";
}
else
oOption.text = ""; //Change the blank option line here e.g - "Select All";
It works for me, but if you have a better idea, please let me know.
Dave
[Updated on: Fri, 08 February 2013 18:46] Report message to a moderator
|
|
|
|
|
| Re: Remove the null values in a multi-value listbox [message #1009492 is a reply to message #1009464] |
Fri, 15 February 2013 03:25  |
David Good Messages: 33 Registered: September 2012 |
Member |
|
|
HI Jason,
Thanks for this, I will give it a try tomorrow (it is Friday PM in Oz right now).
As you know a required parameter does not add the 'Null Value' entry to drop downs, while a non required does. My condition (messages above) in AbstractParamDialog.js worked great for non required params, but cut the first entry from my list when I switched to use a required param.
If I can assess if the param is required in AbstractParamDialog.js I will have something that works for both types of param, using the condition I mentioned:
if ((thisParam.isRequired=false && i!=1)||(thisParam.isRequired=true)) {
All of this is for list boxes only btw.
Thanks for the feedback I will have another look and post my results on Monday when I am back at work.
Have a good weekend.
David
|
|
|
Powered by
FUDForum. Page generated in 0.07663 seconds