Page 2 of 3

Re: add dynamic values to <select> in Forms.xml

PostPosted:Mon Jul 07, 2014 12:00 am
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

Re: add dynamic values to <select> in Forms.xml

PostPosted:Wed Jul 09, 2014 7:14 am
by jllort
Now looks better. Take in mind in select you missed the type="simple" or "multiple"

Re: add dynamic values to <select> in Forms.xml

PostPosted:Mon Jul 14, 2014 4:02 am
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

Re: add dynamic values to <select> in Forms.xml

PostPosted:Wed Jul 16, 2014 6:10 am
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)

Re: add dynamic values to <select> in Forms.xml

PostPosted:Fri Jul 18, 2014 4:49 am
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

Re: add dynamic values to <select> in Forms.xml

PostPosted:Sat Jul 19, 2014 8:34 am
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">

Re: add dynamic values to <select> in Forms.xml

PostPosted:Mon Jul 21, 2014 5:25 am
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

Re: add dynamic values to <select> in Forms.xml

PostPosted:Tue Jul 22, 2014 11:05 am
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.

Re: add dynamic values to <select> in Forms.xml

PostPosted:Thu Jul 24, 2014 5:28 am
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

Re: add dynamic values to <select> in Forms.xml

PostPosted:Thu Jul 24, 2014 6:06 am
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 ).

Re: add dynamic values to <select> in Forms.xml

PostPosted:Thu Feb 05, 2015 7:03 am
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

Re: add dynamic values to <select> in Forms.xml

PostPosted:Fri Feb 06, 2015 10:00 am
by pavila
I'm not sure if this className attribute is implemented in OpenKM Community...

Re: add dynamic values to <select> in Forms.xml

PostPosted:Fri Feb 06, 2015 11:20 pm
by jllort
confirmed community comes with this feature, you should use dtd version 2.3 ( take a look at select definition )
https://sourceforge.net/p/openkm/code/H ... ps-2.3.dtd

Re: add dynamic values to <select> in Forms.xml

PostPosted:Thu Feb 12, 2015 12:14 pm
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...

Re: add dynamic values to <select> in Forms.xml

PostPosted:Fri Feb 13, 2015 6:17 pm
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 ).