Issue in deleting the Value from Property(Type String Array) on the node. | Community
Skip to main content
Ratna_Kumar
Level 10
May 19, 2017
Solved

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

  • May 19, 2017
  • 5 replies
  • 1226 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ratna_Kumar

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.

5 replies

Shivamurthy_MN
Level 2
May 19, 2017

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..

smacdonald2008
Level 10
May 19, 2017

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

MC_Stuff
Level 10
May 20, 2017

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,

kautuk_sahni
Community Manager
Community Manager
May 22, 2017

Did any of the suggestion worked for you?

~kautuk

Kautuk Sahni
Ratna_Kumar
Ratna_KumarAuthorAccepted solution
Level 10
May 22, 2017

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.