Remove the null values in a multi-value listbox [message #690033] |
Tue, 28 June 2011 20: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 20: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 21:33 |
|
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
|
|
|
|
Re: Remove the null values in a multi-value listbox [message #1007916 is a reply to message #690063] |
Fri, 08 February 2013 08:09 |
David Good Messages: 41 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 23:46] Report message to a moderator
|
|
|
|
Re: Remove the null values in a multi-value listbox [message #1009464 is a reply to message #1008123] |
Fri, 15 February 2013 07:33 |
|
David
I am a bit confused. Why are you trying to check if the parameter is required. If it has a null value it is not required. If you need to check it you can use some js like:
var isReq = false;
var fnd = false;
var parametertblrws = document.getElementById( "parameter_table" ).getElementsByTagName( "TR" );
for( var ii = 0; ii < parametertblrws.length; ii++ )
{
var chkrightparm = parametertblrws[ii].getElementsByTagName("input");
for( var jj = 0; jj < chkrightparm.length; jj++){
if( chkrightparm[jj].id == param_name + "_value" ){
fnd = true;
}
if( chkrightparm[jj].id == "isRequired" && fnd){
isReq = chkrightparm[jj].value;
alert( "Param isReq = " + isReq );
}
}
}
The isRequired field is stored in an a hidden input for the parameter.
Hope this helps.
Jason
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02725 seconds