• add dynamic values to <select> in Forms.xml

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #29180  by matt81
 
Thanks for your reply.
To return List<Option>, you mean from package
Code: Select all
import com.openkm.bean.form.Option;
.
I have changed the code as follows.
Code: Select all
import com.openkm.bean.form.Option;
import java.util.List;

public interface OptionSelectValues {
    public List<Option> getOptions();
}
And Java class:
Code: Select all
import com.openkm.api.OKMAuth;
import com.openkm.bean.form.Option;
import com.openkm.rest.util.UserList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListClass implements OptionSelectValues {

    @Override
    public List<Option> getOptions() {
       
       List<Option> options = new ArrayList<Option>();
        Option n = new Option();
        try {
           
        
        UserList users = new UserList();
        List<String> userList = (List<String>) users.getList();
        String token = OKMAuth.getInstance().login("okmAdmin", "admin");
       
        List<String> usersL = OKMAuth.getInstance().getUsers(token);
       
        String name = null;
        int i=0;
        for (Iterator<String> it = usersL.iterator(); it.hasNext(); i++) {
            String usr = it.next();
             name = OKMAuth.getInstance().getName(token, usr.toString());
            
          n.setLabel(name);
          n.setValue(usr.toString());
          options.add(n);
        }
        } catch(Exception e){
            System.out.println("Exceptin occured: " + e.getMessage());
        }
        return options;
    }
}
See attachment of how I think the Forms.xml and PropertyGroup.xml should look like. Correct me if I am wrong.

Thanks Guys
Attachments
property.png
property.png (21.3 KiB) Viewed 6342 times
Forms.png
Forms.png (20.67 KiB) Viewed 6342 times
 #29278  by matt81
 
Thanks for your reply.
Yep so the select statement will look as follows:
Code: Select all
<select label="user" name="user" class="openkm.select.values.ListClass" type="simple" >
Let me know what to do next if everything else is ok.

Thanks
 #29300  by jllort
 
- Change the .dtd to add new attribute what now is not present. Here http://wiki.openkm.com/index.php/Proper ... definition in the third square indicate how to reference local file.
- Change DbPropertyGroupModule.java to take in consideration the change you've done follow the methods:
List<FormElement> getProperties(String token, String nodeId, String grpName)
FormElement getProperty(String token, String nodeId, String grpName, String propName)
public void setProperties(String token, String nodeId, String grpName, List<FormElement> properties)
public List<FormElement> getPropertyGroupForm(String token, String grpName)
 #29327  by matt81
 
Thanks for your reply.
Ok I have changed PropertyGroup.xml to be as the attachment (forms.png). For the DTD I have created a new file where I have added the new attribute "class", see attachment (properties-dtd.png)
I need to know where shoud this new .dtd be stored, where do you guys store these files.
As for the Four methods you described below, the only thing that I woud need to change is the following (except for the setProperties), so it includes the new file. Am I right, please guide me through.
Code: Select all
Map <PropertyGroup, List<FormElement>> pgfs = FormUtils.parsePropertyGroupsForms(Config.PROPERTY_GROUPS_XML);
Please let me know.

Thanks
Attachments
properties-dtd.png
properties-dtd.png (43.99 KiB) Viewed 6323 times
forms.png
forms.png (23.32 KiB) Viewed 6323 times
 #29344  by jllort
 
I suggest a little change because class is reserved word and could be used in nearly future.
Code: Select all
class="openkm.select.values.ListClass"
to
Code: Select all
className="openkm.select.values.ListClass"
You can save file in your hard disk and then write the path, you, read here http://wiki.openkm.com/index.php/Proper ... definition
In linux should be something like
Code: Select all
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.0//EN"
                                 "file:///path/to/property-groups-2.0.dtd">
in Windows I think could be something like:
Code: Select all
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.0//EN"
                                 "file://c:/path/to/property-groups-2.0.dtd">
 #29357  by matt81
 
Thanks for your reply,
I have changed it to "className" everywhere in the code. Is that all I need so far. Can you think of anything else, or is this code now ready for production?
I will save the new .DTD to my local hard disk.

Thanks
 #29374  by jllort
 
Have you tested and is going right ? the changes you've done seems correct, but testing we'll be sure you have not missing any step.
 #29391  by matt81
 
Thanks for your reply.
Well that's a bot tricky. I am currently using 1 version of the running OpenKM, and I did a checkout from the repository on the other which is just the code. That's where I modified and added the files.
Not sure exactly how to link it. What would be an easy option, could I commit the changes and you guys try it locally to see if I missed anything.

Let me know.

Just one thing I noticed is, see code below, when i get the users list I would need to pass a token. I login statically with my usernames. Is there anyway this can be dynamic, how can I grab a curent token?
Code: Select all
String token = OKMAuth.getInstance().login("okmAdmin", "admin");
List<String> usersL = OKMAuth.getInstance().getUsers(token);
Thanks
 #29392  by jllort
 
In Eclipse enable Team View ( Icon at top right -> Open Perspective -> Team Synchronizing Perspective -> you'll see the files changed.
Then select files -> right click ( contextual menu ) -> Team -> Create patch ( .... select project during the wizard, I think is third step and save patch as txt file ).
Add the patch file here or if you want to send us directly contact with me ( send me a private message and I will give you my mail ).
 #31180  by CBD007
 
Hello Guys.....
Need bit of guidence for How can I add class name property to select attribute. I thought there is solution behind this issue to add property DTD in form.xml but when I insert this piece of code
Code: Select all
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.1//EN"
"http://www.openkm.com/dtd/property-groups-2.1.dtd">  
M getting com.openkm.core.ParseException so how can I add class name property to select attribute
 #31258  by CBD007
 
Hello jllort,pavila..
I can able to display list of users based on their role...I stucked at point where I would like to assign task to user from DecisionHandler class so how could i achive this ??? Do u have any idea regarding of how to assign task to users form DecisionHandler class...?? It will be helpful if u have any code snippet of DecisionHandler class with assigning task to users...
 #31282  by jllort
 
Hi CBD007 the problem is you are not seeing the users list ? or you do not know how to assign them to wf ( if it's the second case, please add other post for it, do not merge differents questions on same topic, that will cause confusion on other users ).

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.