Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Remove the null values in a multi-value listbox
Remove the null values in a multi-value listbox [message #690033] Tue, 28 June 2011 16:16 Go to next message
Scroon  is currently offline 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 Go to previous messageGo to next message
Jason Weathersby is currently offline 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 #690063 is a reply to message #690055] Tue, 28 June 2011 18:36 Go to previous messageGo to next message
Scroon  is currently offline Scroon
Messages: 28
Registered: June 2011
Junior Member
Hello Jason,

Thanks for the help!

The blank and null values are gone now.

[Updated on: Tue, 28 June 2011 18:39]

Report message to a moderator

Re: Remove the null values in a multi-value listbox [message #1007916 is a reply to message #690063] Fri, 08 February 2013 03:09 Go to previous messageGo to next message
David Good is currently offline 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 #1008123 is a reply to message #1007916] Sun, 10 February 2013 02:34 Go to previous messageGo to next message
David Good is currently offline David Good
Messages: 33
Registered: September 2012
Member
Hi Jason,

I am at a loss regarding how to determine if a cascading parameter being processed by AbstractParamDialog.js is required, or not.

I can not see where to simply skip processing of the Null Value option but think it has to be in the .js files to be available for the ajax calls (??).

In the AbstractParamDialog.js my condition [previous message] to omit the 'Null Value' entry would need to test if the parameter is required or not. How do I establish a value for the [pseudo] thisParam.isRequired= test below?


line 112:

if ((thisParam.isRequired=false && i!=1)||(thisParam.isRequired=true)) { // start remove 'Null Value' condition

then add another brace just before the for loop's closing brace

} // end remove 'Null Value' condition

Thanks,
David
Re: Remove the null values in a multi-value listbox [message #1009464 is a reply to message #1008123] Fri, 15 February 2013 02:33 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

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


Jason Weathersby

BIRT Exchange
Re: Remove the null values in a multi-value listbox [message #1009492 is a reply to message #1009464] Fri, 15 February 2013 03:25 Go to previous message
David Good is currently offline 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
Previous Topic:source code of BIRT: A Field Guide (third edition)
Next Topic:Tribix PPT emitter for BIRT WebViewer v4.2.1
Goto Forum:
  


Current Time: Mon May 20 22:22:03 EDT 2013

Powered by FUDForum. Page generated in 0.07663 seconds