Expand my Community achievements bar.

SOLVED

Issue in deleting the Value from Property(Type String Array) on the node.

Avatar

Level 10

Hi,

I want to delete the Value in the property that is type String Array. Deleting the value is working fine but I am having in issues in deleting the value.
Suppose I want to delete the value here:

Before deleting:

After deleting the value: 24.56.43.45 I am getting the comma at the end of the values and box getting not deleted along with the value. Please find the screenshots below.

After deleting:

Could anyone let me know, how to delete the entire value with box.

This is my code I used for deletion of value from form.

for(Value val:ipList){
                    log.info(val.getString() + " , ");
                    if(val !=null && val.getString().equals(deleteValue)){                        
                        ipList.remove(val);
                        break;
                    }
                }

Please help me!!

Thanks,
Ratna Kumar.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi All,

Many thanks for your suggestions!! I have resolved the issue. 

I have used the ValueFactory for adding or deleting the value from the property that is String Array. Below is the code I have used.

if (ipValues != null && isDeleteIPExist &&  deleteip != null && !deleteip.trim().equals("")) {
                log.info("Deleting IP Address : " + deleteip);
                
                ValueFactory vFctory = node1.getSession().getValueFactory();
                Value delp = vFctory.createValue(deleteip);
                boolean isDel = ipList.remove(delp);

                log.info("IP Deleted: " + deleteip + " ,is Deleted: " + isDel);
                isModified = true;
                
            }

Thanks,
Ratna.

View solution in original post

5 Replies

Avatar

Level 3

Ratna Kumar wrote...

Hi,

I want to delete the Value in the property that is type String Array. Deleting the value is working fine but I am having in issues in deleting the value.
Suppose I want to delete the value here:

Before deleting:

After deleting the value: 24.56.43.45 I am getting the comma at the end of the values and box getting not deleted along with the value. Please find the screenshots below.

After deleting:

Could anyone let me know, how to delete the entire value with box.

This is my code I used for deletion of value from form.

for(Value val:ipList){
                    log.info(val.getString() + " , ");
                    if(val !=null && val.getString().equals(deleteValue)){                        
                        ipList.remove(val);
                        break;
                    }
                }

Please help me!!

Thanks,
Ratna Kumar.

 

I guess you need to check for empty as well..

Avatar

Level 10

Agreed - looks like you are letting an empty string exist. 

Avatar

Level 9

Hi Ratna,

Either it is not coming inside your custom if condition Or the reference list is wrong. Also just check for empty & not val.getString().equals(deleteValue)

Thanks,

Avatar

Administrator

Did any of the suggestion worked for you?

~kautuk



Kautuk Sahni

Avatar

Correct answer by
Level 10

Hi All,

Many thanks for your suggestions!! I have resolved the issue. 

I have used the ValueFactory for adding or deleting the value from the property that is String Array. Below is the code I have used.

if (ipValues != null && isDeleteIPExist &&  deleteip != null && !deleteip.trim().equals("")) {
                log.info("Deleting IP Address : " + deleteip);
                
                ValueFactory vFctory = node1.getSession().getValueFactory();
                Value delp = vFctory.createValue(deleteip);
                boolean isDel = ipList.remove(delp);

                log.info("IP Deleted: " + deleteip + " ,is Deleted: " + isDel);
                isModified = true;
                
            }

Thanks,
Ratna.